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