How can I have is null condition in typeorm find options?

user4092086 picture user4092086 · Oct 23, 2017 · Viewed 18k times · Source

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

Answer

hungneox picture hungneox · Jan 25, 2019

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

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