Created
October 13, 2011 08:29
-
-
Save zolzaya/1283740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> db.system.js.save({_id:"last_n_users", value: function(n){return db.users.find().sort({created_at:-1}).limit(n).toArray()}}) | |
> db.eval("last_n_users(3)") | |
[ | |
{ | |
"_id" : ObjectId("4e8c2a00de570598c220878b"), | |
"username" : "Zoloo", | |
"created_at" : ISODate("2011-10-04T16:00:00Z"), | |
"password" : "secret", | |
"last_visited_at" : ISODate("2011-10-04T16:00:00Z") | |
}, | |
{ | |
"_id" : ObjectId("4e8d0d800ec65305be4f6568"), | |
"username" : "Unuruu", | |
"password" : "barfoo", | |
"created_at" : "Thu Oct 06 2011 10:08:00 GMT+0800 (ULAT)" | |
}, | |
{ | |
"_id" : ObjectId("4e8d02690ec65305be4f6566"), | |
"username" : "Darmaa", | |
"created_at" : "Thu Oct 06 2011 09:20:33 GMT+0800 (ULAT)" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment