Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created September 2, 2011 02:30
Show Gist options
  • Select an option

  • Save aheckmann/1187809 to your computer and use it in GitHub Desktop.

Select an option

Save aheckmann/1187809 to your computer and use it in GitHub Desktop.
var mongoose = require('./mongoose')
mongoose.connect('localhost', 'testing_487');
var Schema = mongoose.Schema;
var db = mongoose.connection;
var S = new Schema({a: String, b: String});
var A = db.model('A', S);
var a = new A({a:"hi",b:"bye"});
a.save(function (err) {
if (err) return console.error(err.stack||err);
A.find({}, function (err) {
if (err) return console.error(err.stack||err);
A.update({a:"hi"}, { $set: { b: "goooooobye" }}, function (err) {
if (err) return console.error(err.stack||err);
A.find({}, function (err, docs) {
if (err) return console.error(err.stack||err);
console.error('done. found', docs);
mongoose.connection.db.dropDatabase(function () {
mongoose.connection.close();
});
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment