How can I have is null condition in typeorm find options?
If someone is looking for NOT NULL, it would be like this:
import { IsNull, Not } from "typeorm";
return await getRepository(User).findOne({
where: {
username: Not(IsNull())
}
});
Another way is you can use IsNull()
function, for example:
import { IsNull } from "typeorm";
return await getRepository(User).findOne({
where: {
username: IsNull()
}
});
You can use QueryBuilder for this purpose:
const users = await userRepository.createQueryBuilder("user")
.where("user.name IS NULL")
.getMany();