Skip to content

Instantly share code, notes, and snippets.

@guange2015
Created December 5, 2012 15:18
Show Gist options
  • Select an option

  • Save guange2015/4216457 to your computer and use it in GitHub Desktop.

Select an option

Save guange2015/4216457 to your computer and use it in GitHub Desktop.
mongo.js
var dburl = 'localhost/mongoapp';
var collections = ['users'];
var db = require('mongojs').connect(dburl,collections);
db.users.save({
name: 'hello',
email: 'hello@world.com'
});
db.users.find({},function (err, users) {
if(err || !users) console.log("No female users found");
else users.forEach(function (user) {
console.log(user);
})
})
//process.exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment