如何获得适用于此 Mongoose 查询的“大于”语法?
var where = {};
where._id = req.wine.id;
where.sameAs = undefined;
where.scoreTotal > 0; //THIS NEEDS TO SET TO DO GREATER THAN 0
where.mode = 'group';
where.deleted = false;
Wine.find(where, callback).populate('user');
它不断使我的节点服务器崩溃。
为了便于阅读,我想保留这个 where 对象语法,而不是执行内联 where 对象语法。我可以做类似的事情:
where.scoreTotal = $gt(0);
原文由 tonejac 发布,翻译遵循 CC BY-SA 4.0 许可协议
参考官方文档以获得清晰的解释和完整的使用细节: http ://mongoosejs.com/docs/queries.html
而不是
where.scoreTotal > 0
添加
"where.scoreTotal" : { $gt : 0}