TypeORM - boolean in where clause not work propely

Viewed 2668

I have a problem with where clause and boolean value in TypeORM, like below:

async getUserProjects(user: User, isFavorite: boolean): Promise<User[]> {
        const data = await this.conn.getRepository(User).find({
            where: {
                userId: user,
                favorite: isFavorite
            },
        })
  @Column({
    type: 'bool'
  })
  favorite: boolean;

why this find not work properly and always return me value where favorite is false? when my fav == true return me all data when favorite == false..., can someone tell me what is wrong here?

1 Answers
const data = await this.conn.getRepository.find(User,{
            where: {
                userId: user,
                favorite: isFavorite
            },

I tried this code it's working for me. find<Entity>(entityClass: EntityTarget<Entity>, conditions?: FindConditions<Entity>): Promise<Entity[]>;

Related