0

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 {}

1 Answers1

0

You should try out feathers It has good community, It has some learning curve but since you know knex then you can easily adopt it.

Pash
  • 345
  • 4
  • 11