1// getting-started.js
2const mongoose = require('mongoose');
3mongoose.connect("mongodb://localhost:27017/name", { useUnifiedTopology: true, useNewUrlParser: true });
1const db = mongoose.connection;
2db.on('error', console.error.bind(console, 'connection error:'));
3db.once('open', function() {
4 // we're connected!
5});
1const mongoose = require('mongoose');
2mongoose.connect("mongodb://localhost:27017/name", { useUnifiedTopology: true, useNewUrlParser: true });