mongodb - Create "$in" query with a "limit per match"? -
i have collection of users , collection of images. each image doc stores guid of user/creator. given set of 4 users (for example), want build query retrieve each user's 5 latest images. there "limit per criteria" operator can accomplish 1 request? like:
db.images.find( { 'creatorguid' : { '$in' : arrayofuserguids , '$limitpermatch' : 5 } } )
if it's not possible 1 request, what's efficient way to kind of query?
not possible @ moment, mongodb kind of "knows" , returns, doesn't deign see how many matches there per clause of range query.
the way can think of doing query each of creatorguid
s separately limit(5)
.
horrid , bad way can think of in case.
mongodb pymongo
No comments:
Post a Comment