繁体   English   中英

MongoDB:如何获取具有特定属性的文档深入对象结构内部?

[英]MongoDB: how to get document with specific propety deep inside the object structure?

如何从RockMongo和PHP获得带有“ test”:NumberInt(1000)属性的MongoDB文档?

我尝试了类似的方法来{{items“:{” test“:1000}} ,但是

找不到记录。

Mongo收集样本:

{
   "_id": ObjectId("xxx"),
   "items": {
     "0": {
       "0": {
         "test": NumberInt(1000)
        }
      },
       "1": {
         "test": NumberInt(2000)
        },
    },
},
{
   "_id": ObjectId("yyy"),
   "items": {
     "0": {
       "0": {
         "test": NumberInt(3000)
        }
      },
       "1": {
         "test": NumberInt(4000)
        },
    }
}

尝试这个

db.coll.find( { 'items.test': 1000 } )

并确保items是一个array而不是一个object

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM