I'm looking for solution to use BaseService for common Objection model methods. it is working properly on UserService. but i want to write some methods in BaseService class.
base.service.ts
class BaseService<Models>{
public m: Models;
constructor(model: Models) {
this.m = model;
}
//Not working
public find(): Promise<any> {
return await this.m.query().findAll();
}
}
user.service.ts
class UserService extends BaseService<typeof UserMoodel> {
constructor() {
super(UserModel)
}
getUsers() : Promise<User> {
return await this.m.query().findAll().toCast<User>();
}
}
user.model.ts
class UserMoodel extends Model {}