-
-
Save jroes/3005679 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
var mongoose = require('./../mongoose'); | |
console.error( | |
'\n===========' | |
, ' mongoose version: ' | |
, mongoose.version | |
, '========\n\n' | |
); | |
var Schema = mongoose.Schema; | |
mongoose.connect('localhost', 'testing_saveorder'); | |
mongoose.connection.on('error', function () { | |
console.error(arguments); | |
}); | |
var schema = new Schema({ | |
name: String | |
}); | |
schema.pre('save', function (next) { | |
console.error('pre save'); | |
next(); | |
}); | |
schema.post('save', function () { | |
console.error('post save start'); | |
A.update({}, {name: 'b'}, function(err, numAffected) { | |
if (err) { | |
console.error(err); | |
return; | |
} | |
console.error('post save end', numAffected); | |
return; | |
}); | |
}); | |
var A = mongoose.model('A', schema); | |
mongoose.connection.on('open', function () { | |
var a = new A({ name: 'saveorder' }); | |
a.save(function (err, a) { | |
console.error('save callback'); | |
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