python - mongodb get element in multi array -
i have mongodb document this:
{ "post":[ { "name": "post1", "part": [ { "name": "part1", ... },{ "name": "part2", ... } ] },{ "name": "post2", "part": [ { "name": "part3", ... },{ "name": "part4", ... } ] } ... ] }
i want output this:
{ "post": [ { "part":[ { "name": "part2" } ] } ] }
my query this:
db.find_one({"_id": 123},{ "post.%s.part.%s.name" % (0, 1) : 1 })
i known index of list post (is 0) , part (is 1)
i can't index of output, can help me element of array ? have seek $slice, how query $slice in multi part of array thanks!
projection can't project out specific elements except matching $. can restrict field "post.part.name"
(but still getting field value each element of bottom-level array).
python mongodb
No comments:
Post a Comment