我如何检查node-orm中NULL值的列

我在node.js中使用orm包,我试图在我的一个模型上使用find()查询数据库。 但是,我不知道如何使用find()检查列的NULL值。 有没有办法做到这一点?

如果sent_at字段没有设置,那么:

 db.emails.find({sent_at: {$exists: false}}) 

如果它在那里,而且根本不存在:

 db.emails.find({sent_at: null}) 

参考: 查询nul字段

注意:由于您没有提到数据库名称,也没有提到您将数据库作为mongodb使用的orm。

希望这可以帮助。

如何将null置于条件

 schema.find({ col: null}, function (err, people) { … }); 

要么

 schema.count({ col: null }, function (err, count) { console.log("We have %d Does in our db", count); }); 

文档还说,你可以做原始查询

 db.driver.execQuery( "SELECT * FROM table WHERE col IS NOT NULL", function (err, data) { ... } )