Sequelize lazy loading missing get method

Viewed 14

I am trying to use Sequelize lazy loading in my project but there is no get___ method for the associations.

@Injectable()
export class someService {
  constructor(private sequelize: Sequelize) {}

  async createById(
    t: Transaction,
    dto: CreateDto,
  ) {
    const userRepo = this.sequelize.getRepository(UserModel);

    const [userModel] = await userRepo .findOrBuild({
      where: { refId: dto.id },
      defaults: { refPatientId: dto.patientId },
    });

    console.log(userModel.getBooks());
  }
}

then this prompted: Property 'getBooks' does not exist on type 'UserModel'. Did you mean 'books'?

0 Answers
Related