Friday, 15 January 2010

mongodb - Create "$in" query with a "limit per match"? -



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 creatorguids separately limit(5).

horrid , bad way can think of in case.

mongodb pymongo

No comments:

Post a Comment