daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mongoose = require('mongoose');
  2. mongoose.connect('mongodb://localhost/test');
  3. var kittySchema = new mongoose.Schema({
  4.   name: String
  5. });
  6. var Kitten = mongoose.model('Kitten', kittySchema);
  7. var fluffy = new Kitten({ name: 'fluffy' });
  8. fluffy.save(function (err, fluffy) {
  9.   if (err) return console.error(err);
  10.   console.log('saved');
  11. });
  12.    
  13. var mongoose = require('mongoose');
  14. //WITHOUT CONNECT!!!
  15. var kittySchema = new mongoose.Schema({
  16.   name: String
  17. });
  18. var Kitten = mongoose.model('Kitten', kittySchema);
  19. var fluffy = new Kitten({ name: 'fluffy' });
  20. fluffy.save(function (err, fluffy) {
  21.   if (err) return console.error(err);
  22.   console.log('saved');
  23. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top