I开发者_高级运维 have top-level document User with embedded Keyword documents (User EmbedMany Keyword). Well i don't know how to get Keyword object from concrete User by Keyword's id I spent a lot of time trying to solve this but it still open problem for me. So i help someone here will help me. Thanks a lot.
You can load only parent document from the mongodb. But there is $slice operator that can load parent document just with limited number of embedded documents.
On native mongodb language you can do it so:
db.users.find({_id: "UserId", "Keywords._id", "keywordId"},
{Keywords:{$slice: 1}}) // first matched by id keyword
From doctrine you will receive user document with only one embedded keyword.
Hope this helps.
精彩评论