Mongoose中“SELECT * WHERE city!= null”的模拟

问题是,如何在我的数据库中find数据,哪里city != null

  userdata.find({ /*???*/ }, function (err, results) { if (!err) console.log(results) ... }); 

你可以使用$exists 。 文档在这里

它应该是这样的

 useedata.find({ city: { $exists: true } }, function(error, results) { if (!error) console.log('results' + results) })