ortense
10/21/2015 - 12:41 AM

MongoDB with auth + Mongoose + ES6

MongoDB with auth + Mongoose + ES6

'use strict';
const mongoose = require('mongoose');

mongoose.connect('mongodb://user:pass@localhost/base?authSource=admin');

let Cat   = mongoose.model('Cat', { name: String });
let kitty = new Cat({ name: 'Kitty' });

kitty.save( err => {
  if (err) console.log(err);
  console.log('meow');
});