如何在 Waterline 中编写 NOT Equal 条件?
这段代码:
Users
.count()
.where({
id: { '!=': req.params.id},
lastname: req.body.lastname
})
什么都不做...(sails.js 中的磁盘适配器)
最佳答案
首先,它什么都不做,因为查看数据库是异步的。您必须使链更长,然后添加 exec 或 Q 库中的其他内容。
User.count().where({
id: { '!=': req.params.id },
lastname: req.body.lastname
}).exec(function(err, num){
console.log(num);
});
现在它返回 0。要让它返回正确的数字而不是 '!=',只需写 '!'。
关于javascript - 查询中不等于的 Waterline ORM (sails.js) 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20378997/