如何在 typeorm 查找选项中使用 null 条件? [英] How can I have is null condition in typeorm find options?

查看:91
本文介绍了如何在 typeorm 查找选项中使用 null 条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的查询中,我使用 typeorm 查找选项,如何在 where 子句中有 IS NULL 条件?

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

推荐答案

另一种方式是你可以使用 IsNull() 函数,例如:

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

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

这篇关于如何在 typeorm 查找选项中使用 null 条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆