nodejs - mongodb - 如何找到所有的地方!= b?

ang*_*iwi 5 mongodb node.js

这就是我的想象

    //b is variable
    collection.findAll({a:'!'+b}function(err, cursor) {

    });
Run Code Online (Sandbox Code Playgroud)

该查询的正确方法是什么,找到所有结果的地方!= b?

Atz*_*oya 19

您可以使用not equals'$ ne'进行比较

collection.findAll({a: {'$ne':b }}, function(err, cursor) {});
Run Code Online (Sandbox Code Playgroud)

有关更详细的说明,请查看此高级查询手册页.