[英]typeorm QueryBuilder: how to match column value of boolean?
在 Typeorm 查询生成器中,当我想匹配其值等于 True 的 boolean 的行时,语法是什么样的?
例如,我有这个工作代码:
await getConnection()
.createQueryBuilder()
.delete()
.from(Notification)
.where("id = :id", { id: 1 })
.andWhere('dstOrgId = :dstOrgId', { dstOrgId: 1001 })
.execute();
但是,如果我想匹配clicked
列的值为 boolean True
的所有行,我应该怎么写?
我想做类似的事情:
await getConnection()
.createQueryBuilder()
.delete()
.from(Notification)
.where("clicked = :x", { x: true })
.andWhere("viewed = :x", { x: false })
.execute();
但是上面的代码似乎不是很好的语法,或者“正确”的语法
这应该对所有人都有帮助
需要使用@Column 属性“变压器”
此建议已被 typeorm 团队分享
https://github.com/typeorm/typeorm/issues/3875 https://github.com/typeorm/typeorm/issues/3942
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.