Guest User

Untitled

a guest
Jan 23rd, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2. var mongoose = require('./mongoose')
  3. mongoose.connect('localhost', 'testing_487');
  4.  
  5. var Schema = mongoose.Schema;
  6.  
  7. var db = mongoose.connection;
  8.  
  9.  
  10. var S = new Schema({a: String, b: String});
  11. var A = db.model('A', S);
  12.  
  13. var a = new A({a:"hi",b:"bye"});
  14. a.save(function (err) {
  15. if (err) return console.error(err.stack||err);
  16. A.find({}, function (err) {
  17. if (err) return console.error(err.stack||err);
  18. A.update({a:"hi"}, { $set: { b: "goooooobye" }}, function (err) {
  19. if (err) return console.error(err.stack||err);
  20. A.find({}, function (err, docs) {
  21. if (err) return console.error(err.stack||err);
  22. console.error('done. found', docs);
  23. mongoose.connection.db.dropDatabase(function () {
  24. mongoose.connection.close();
  25. });
  26. })
  27. })
  28. })
  29. })
Add Comment
Please, Sign In to add comment