Created
May 15, 2012 00:09
-
-
Save ovaillancourt/2698214 to your computer and use it in GitHub Desktop.
Shutting down after a bunch of mongoose transactions.
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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var FooSchema = new Schema({ | |
dob: { type: Date}, | |
num: {type : Number}, | |
}); | |
Foo = mongoose.model('Foo', FooSchema); | |
mongoose.connect("mongodb://test:[email protected]/test", function(){ | |
console.log('connected!'); | |
}); | |
console.log('calling remove'); | |
Foo.remove({}, function(err) { | |
var f; | |
f = new Foo({ | |
dob: Date.now(), | |
num: 1, | |
test : { | |
bla: 2 | |
} | |
}); | |
console.log('calling save'); | |
f.save(function(err) { | |
Foo.find().$or([{'num' : 1},{'test.bla' : 3}]).run(function(err, doc) { | |
console.log(doc); | |
mongoose.disconnect(function(){ | |
console.log('disconnected! byebye!'); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment