Node.js mongoose: how to use the .in and .sort methods of a query?

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2010-12-23T23:20:55Z Indexed on 2010/12/25 21:54 UTC
Read the original article Hit count: 341

Filed under:
|
|
|

Hi there,

I'm trying to wrap my head around mongoose, but I'm having a hard time finding any kind of documentation for some of the more advanced query options, specifically the .in and .sort methods. What's the syntax for sorting, for example, a Person by age?

db.model("Person").find().sort(???).all(function(people) { });

Then, let's say I want to find a Movie based on a genre, where a Movie can have many genres (in this case, an array of strings). Presumably, I'd use the .in function to accomplish that, but I'm not sure what the syntax would be. Or perhaps I don't have to use the .in method at all...? Either way, I'm lost.

db.model("Movie").find().in(???).all(function(movies) { });

Anyone have any ideas? Or even better, a link to some comprehensive documentation?

Thanks!
Chris

© Stack Overflow or respective owner

Related posts about query

Related posts about mongodb