【问题标题】:Multiple Inputs in ne mongoose methodne mongoose 方法中的多个输入
【发布时间】:2021-01-19 05:29:38
【问题描述】:

我有用户集合,我想获取所有用户其中状态不等于“已删除”“待定”

我试过了

users.find().where('status').ne('deleted').where('status').ne('pending')

但它不起作用。

我也试过了

users.find().where('status').ne(['deleted','pending'])

也不行。

我将如何完成它?

我知道可以使用嵌套查询字符串来完成,但我想要一种借助这些查询方法的方法。

【问题讨论】:

    标签: node.js mongodb mongoose nosql


    【解决方案1】:

    如果你想做多个 $ne 然后做

    users.find({status: {$nin : ["deleted", "pending"]}})
    

    https://docs.mongodb.com/manual/reference/operator/query/nin/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-07
      • 2011-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多