duanqianruan8448 2014-02-16 16:28
浏览 201
已采纳

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

How can I get MongoDB-document with "test": NumberInt(1000) property from RockMongo and from PHP?

I tried something alike to {"items": {"test": 1000}}, but

No records is found.

Sample of Mongo collection:

{
   "_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)
        },
    }
}
  • 写回答

1条回答 默认 最新

  • duanluwei9374 2014-02-16 16:55
    关注

    Try this

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

    and assure that items is an array and not an object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 变数的长度不一样”。是什么原因呢?如何修改?
  • ¥15 matlab作业不会写
  • ¥15 vue2(标签-chrome|关键词-浏览器兼容)
  • ¥15 python网络流自动生成系统 医学领域
  • ¥15 sql查询仓库里都有什么
  • ¥15 代码的修改,添加和运行完善
  • ¥15 krpano-场景分组和自定义地图分组
  • ¥15 lammps Gpu加速出错
  • ¥15 关于PLUS模型中kapaa值的问题
  • ¥15 关于博途V17进行仿真时无法建立连接问题