How to query data from mongoDB which column is an array
{ "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'}})
精彩评论