find all with :order for embedded document

19 views
Skip to first unread message

Kyle Bragger

unread,
Jan 15, 2010, 1:50:12 PM1/15/10
to MongoMapper
If I have a Post model, which has many Messages, how can I do
something like this:

@msgs = @post.messages.find(:all, :order => 'foo DESC')

Kyle Banker

unread,
Jan 15, 2010, 2:03:26 PM1/15/10
to mongo...@googlegroups.com
Are messages embedded or are they first-class documents?  If they're embedded, then the sort can only be performed client-side.  It's possible that MongoMapper handles this, though.

John?

--
You received this message because you are subscribed to the Google
Groups "MongoMapper" group.
For more options, visit this group at
http://groups.google.com/group/mongomapper?hl=en?hl=en

Kyle Bragger

unread,
Jan 15, 2010, 2:13:49 PM1/15/10
to MongoMapper
They use EmbeddedDocument. It occurred to me to do client-side
sorting, but I'd have to take in to consideration pagination and the
like...

On Jan 15, 2:03 pm, Kyle Banker <k...@10gen.com> wrote:
> Are messages embedded or are they first-class documents?  If they're
> embedded, then the sort can only be performed client-side.  It's possible
> that MongoMapper handles this, though.
>
> John?
>

John Nunemaker

unread,
Jan 15, 2010, 2:22:39 PM1/15/10
to mongo...@googlegroups.com
You are on your own with embedded docs for now. Someday this might be built in, though it is really just a little bit of ruby.

Kyle Bragger

unread,
Jan 15, 2010, 2:37:44 PM1/15/10
to MongoMapper
Fair enough, thanks.

On Jan 15, 2:22 pm, John Nunemaker <nunema...@gmail.com> wrote:
> You are on your own with embedded docs for now. Someday this might be built
> in, though it is really just a little bit of ruby.
>

Reply all
Reply to author
Forward
0 new messages