Unique entry per user sorted by date

7 views
Skip to first unread message

Jeroen Roodnat

unread,
Jul 20, 2011, 5:31:50 AM7/20/11
to mongodb-user
Hi,

I need some tips and tricks on the following problem.

I have a collection where I story activity per user. Field are
user_id, activity and created_at.
I want to show the last 20 entries but only a user can only show up
once in the result. So the last activity per user sorted by created_at
descending.

I have looked into using map reduce for this but I am stuck at the
moment with any kind of result that works.


Jeroen

Eliot Horowitz

unread,
Jul 20, 2011, 5:48:17 AM7/20/11
to mongod...@googlegroups.com

I think you should try just getting data sorted by time and then doing the unique filter client side. 

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
Reply all
Reply to author
Forward
0 new messages