【发布时间】:2019-06-19 14:23:54
【问题描述】:
我是 MongoDB 新手,正在尝试执行查询。我有一个公司集合和公司 ID 数组。我想得到attributes.0.ccode 存在且attributes.0.ccode 不为空的结果,并将在数组中提供的ID 中进行检查(cdata)
var query = Company.find({ _id: { $in: cdata } },{ "attributes.0.ccode": { $exists: true }, $and: [ { "attributes.0.ccode": { $ne: "" } } ] }).select({"attributes": 1}).sort({});
我得到的错误是
"$err": "Can't canonicalize query: BadValue Unsupported projection option: attributes.0.ccode: { $exists: true }",
"code": 17287
我认为这是一个括号问题,但不知道在哪里。
非常感谢任何帮助。
【问题讨论】:
标签: arrays mongodb mongodb-query