Using Micro-ORM 5.7. I have an entity defined as
class User {
@PrimaryKey({ type: 'varchar', length: 250 })
private id: string;
@Property({ name: 'first_name', length: 50 })
private first_name: string;
Have a DAO layer something like-
@injectable()
export default class UserDAO {
private async getUserRepository(): Promise<EntityRepository<User>> {
const repository = await this.getRepository<User>(User);
return repository;
}
public async findByUserId(id: string): Promise<User> {
const repository = await this.getUserRepository();
const user = (await repository.findOne({ id })) as User;
return user;
}
}
But this always gives error for await repository.findOne({ id }) as
Argument of type '{ id: string; }' is not assignable to parameter of type 'FilterQuery'. Object literal may only specify known properties, and 'id' does not exist in type 'FilterQuery'.
User has ID as PK then not able to understand why TS is saying 'id' does not exist in type 'FilterQuery<User>'