希望执行以下查询:
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 } })
一些可能有帮助的链接:
https://stackoverflow.com/questions/16531895/
相关文章:
mongodb - $lookup 查找数组中的 ObjectId
javascript - node.js mongodb 通过_id node-mongodb-na
mongodb - 无法验证到 mongo, "auth fails"
mongodb - Meteor 应用程序 — 重置已部署应用程序的数据库
node.js - Mongoose findByIdAndUpdate 没有返回正确的模型
python - 用于 Python 的 MongoDB ORM?
MongoDB select count(distinct x) on an indexed col
mongodb - MongoDB 中 Multi-Tenancy 数据库的推荐方法是什么?