1
가 나는 다음 컬렉션 MongoDB의에서 'CanvasCollection'라는 이름의 한 나는이 컬렉션에서 배열에서 "50e6fcc2edcbc10613000022"의 id를 가진 이미지 객체를 얻으려면 :MongoDB에서 컬렉션 내의 배열에서 특정 요소를 가져 오는 방법은 무엇입니까?
{
"_id": ObjectId("50d1f440471ca84e1f000007"),
"image": [{
"_id": ObjectId("50e6fcc2edcbc10613000022"),
"type": "image",
"filename": "50e6fcc2edcbc10613000022.jpg",
"origname": "2811879134_7a57d7c586_m.jpg",
"filepath": "upload/50e6fcc2edcbc10613000022.jpg",
"thumbpath": "upload/50e6fcc2edcbc10613000022_small.jpg",)
}],
"text": [{
"_id": ObjectId("50e6eda0edcbc1061300001b"),
"content": "Type your text here"
}]
}
이 작동하지 않는 것 :하는 방법을
CanvasCollection.find({'_id': new BSON.ObjectID('50d1f440471ca84e1f000007')}, {'image' : {$elemMatch: {'_id': new BSON.ObjectID('50e6fcc2edcbc10613000022')}}})
모든 아이디어를 정확히 :
{
"_id": ObjectId("50e6fcc2edcbc10613000022"),
"type": "image",
"filename": "50e6fcc2edcbc10613000022.jpg",
"origname": "2811879134_7a57d7c586_m.jpg",
"filepath": "upload/50e6fcc2edcbc10613000022.jpg",
"thumbpath": "upload/50e6fcc2edcbc10613000022_small.jpg",)
}