SHARE
TWEET

Untitled

a guest May 24th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const mongoose = require('mongoose')
  2. mongoose.connect('mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs0', { useNewUrlParser: true })
  3.   .then(() => {
  4.     var kittySchema = new mongoose.Schema({
  5.       name: String
  6.     });
  7.     var Kitten = mongoose.model('Kitten', kittySchema);
  8.     var silence = new Kitten({ name: 'Silence' });
  9.     console.log(silence.name); // 'Silence'
  10.     silence.save()
  11.   })
  12.   .catch(console.log)
  13.  
  14. var db = mongoose.connection;
  15. db.on('error', console.error.bind(console, 'connection error:'));
  16. db.on('connected', function() {
  17. console.log('we\'re connected!')
  18. });
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