没有$ expr中的文档字段阵列



我正在尝试获取数组excluded中没有_id的所有文档。

db.sites.find({ "$expr": { '_id': { "$not": { "$in": "$excluded"} } } });

我不使用$nin,因为$expr不允许使用。

我会收到以下错误消息:

Error: error: {
    "ok" : 0,
    "errmsg" : "Expression $in takes exactly 2 arguments. 1 were passed in.",
    "code" : 16020,
    "codeName" : "Location16020"
}

我可以使用$where吗?

操作员中的$需要两个参数:

db.sites.find({ $expr: { $not: { $in: [ "$_id", "$excluded" ] } } })

在这里工作示例

最新更新