Skip to content

Instantly share code, notes, and snippets.

@caged
Created June 18, 2010 21:31
Show Gist options
  • Save caged/444255 to your computer and use it in GitHub Desktop.
Save caged/444255 to your computer and use it in GitHub Desktop.
var db = new mongo.Db('mydatabase', new mongo.Server("127.0.0.1", 27017, {}));
db.open(function(e, db) {
get('/', function() {
var $this = this
db.collection('some-collection', function(e, col){
col.find({}, {}, function(e, items) {
items.each(function(err, item) {
sys.puts(sys.inspect(item))
})
$this.respond(200)
})
})
})
get('/foo', function() {
var $this = this
db.collection('another-collection', function(e, col){
col.find({}, {limit: 10}, function(e, items) {
items.each(function(err, item) {
sys.puts(sys.inspect(item))
})
$this.respond(200)
})
})
})
run()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment