Is your feature request related to a problem? Please describe.
We should be able to add methods to customise the behaviour models and documents.
Something like this...
interface UserProps {
id: number;
name: string;
}
interface UserMethods {
sayHello: () => string;
}
interface UserStatics {
count: () => number;
}
const schema = Joi.object(...);
const methods: UserMethods = {
sayHello(): string {
return `Hi, I'm ${this.name}`;
}
};
const statics: UserStatics = {
count(): number {
const n = countTheItemsInTheTableSomehow()
return n;
}
};
const Users = new jedlik.Model<UserProps, UserStatics, UserMethods>({ table: 'users', schema, statics, methods });
Users.count(); // returns 0;
const user = User.create({ id: 1, name: 'Michael' });
await user.save()
Users.count(); // returns 1;
user.sayHello(); // returns 'Hi, I'm Michael'
Is your feature request related to a problem? Please describe.
We should be able to add methods to customise the behaviour models and documents.
Something like this...