Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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();
- });
- })
- })
- })
- })
Add Comment
Please, Sign In to add comment