Search code examples
sqlwhere-clausetypeormtypeorm-activerecord

How can I have IS NULL condition in TypeORM find options?


In my queries I'm using TypeORM find option. How can I have IS NULL condition in the where clause?


Solution

  • Another way is you can use IsNull() function, for example:

    import { IsNull } from "typeorm";
    return await getRepository(User).findOne({
        where: { 
          username: IsNull()
        }
    });