希望执行以下查询:
Entrant
.find
enterDate : oneMonthAgo
confirmed : true
.where('pincode.length > 0')
.exec (err,entrants)->
我是否正确地执行了 where 子句?我想选择 pincode
不为空的文档。
最佳答案
您应该能够这样做(因为您正在使用查询 api):
Entrant.where("pincode").ne(null)
... 这将导致类似以下的 mongo 查询:
entrants.find({ pincode: { $ne: null } })
一些可能有帮助的链接:
关于mongodb - 值不为空的 Mongoose 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16531895/