是否可以在Mongo查询中使用类似"exists"的内容来根据ID返回此记录?
像'ids'包含关键字'123456'的选项?
  {
      "department": "Digging",
      "ids": {
        "123456": {
          "color": "blue"
        },
        "123457": {
          "color": "red"
        }
      }
    }
Ada*_*Dev 21
当您搜索具有给定名称的字段时,$ exists是您需要的运算符(请参阅高级查询).
例如:
db.YourCollection.find({ "ids.123456" : {$exists: true}});
| 归档时间: | 
 | 
| 查看次数: | 6454 次 | 
| 最近记录: |