开发者

How to query data from mongoDB which column is an array

开发者 https://www.devze.com 2023-04-04 23:12 出处:网络
{ \"name\": \"Grieg And Sibelius Song开发者_如何学编程s\", \"status\": 1, \"lastupdate\": 1306294550,

{ "name": "Grieg And Sibelius Song开发者_如何学编程s", "status": 1, "lastupdate": 1306294550, "intro": "", "artist": [ "ar9341cd00668311e0a45217d9fa59cf02", "ar9341cd00668311e0a45217d9fa59cf0x" ], "publisher": "(Warner Music)", "release_date": "2006-05-08"

}

I want to find the the data that artist column "ar9341cd00668311e0a45217d9fa59cf02" in array("ar9341cd00668311e0a45217d9fa59cf02","ar9341cd00668311e0a45217d9fa59cf0d","ar9341cd00668311e0a45217d9fa59cf0r") what should I do?


You can use $exists to check the presence of the item in array,

db.yourcollectionname.find({artist: {$exists:'ar9341cd00668311e0a45217d9fa59cf02'}})
0

精彩评论

暂无评论...
验证码 换一张
取 消