[英]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.