MongoDB数据查询

 

 

{
  "_id" : ObjectId("5382a76b723497651a3d49ef"),
  "name" :"世界杯",
  "comments" : [{
      "id" : "20140610001",
      "name" : "不错"
    }, {
      "id" : "20140610002",
      "name" : "巴西"
    }],
   "status":1
}

 

 

   查询状态==1,评论数=2,且评论中内容是“巴西”的记录

    

{"status":1,"comments":{"$elemMatch":{"name":"巴西"},"$size":2}}

 

 

你可能感兴趣的:(mongodb)