Skip to content

Commit

Permalink
Merge pull request #33 from imbolo/master
Browse files Browse the repository at this point in the history
add a simple sorts implemention for find()
  • Loading branch information
amark committed Nov 13, 2013
2 parents e9c5533 + 2cbe13b commit 0ee6ba7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -63,7 +63,7 @@ Done. App development has never felt as close to the shell as this! Making it a
<br/>Ex: <code>{ name: 1, age: 1 }</code>
- third object
is any of the following options:
<br/> <code>{ lim: x, skip: y }</code>
<br/> <code>{ lim: x, skip: y, sort:{age: 1} }</code>
- Numbers
- first number
is the limit (return all if not specified)
Expand All @@ -82,6 +82,8 @@ Done. App development has never felt as close to the shell as this! Making it a
reply.documents skips the first 2 documents and is the next 3 documents.
- <code>db('blog.users').find(function(reply){ }, {age: 25}, {}, {limit: 5, skip: 2})</code><br/>
is the same as the previous example except only of doucments with the age of 25.
- <code>db('blog.users').find({}, {}, {sort: {age: -1}}, function(reply){ })</code><br/>
reply.documents is sorted by age in a decsending (acsending while it is {age:1} ) order.
- **Operations** <code>db('blog.$cmd').find(command,1)</code>
- command
is the database operation command you want to perform.
Expand Down
3 changes: 2 additions & 1 deletion mongous.js
Expand Up @@ -304,6 +304,7 @@ mongous = function() {
q = obj[0] ? obj[0] : {};
f = obj[1] ? obj[1] : null;
o = obj[2] ? obj[2] : {};
if(o.sort != void 0) q = {$query: q, $orderby: o.sort};
o = {
lim: o.lim !== void 0 ? o.lim : num[0] ? num[0] : 0,
skip: o.skip !== void 0 ? o.skip : num[1] ? num[1] : 0
Expand Down Expand Up @@ -390,4 +391,4 @@ db = function() {
}
return db;
}();
exports.Mongous = db;
exports.Mongous = db;

0 comments on commit 0ee6ba7

Please sign in to comment.