Installing MongoDB
suggest changenpm install mongodb
# Mongoose is a schema wrapper around the driver
npm install mongoose
In the server file (index.js or server.js). Mongoose 6 removed the connect callback; the call returns a promise. The scheme is mongodb://, not http://.
const mongoose = require('mongoose');
const mongoConnectString = 'mongodb://localhost:27017/databaseName';
mongoose.connect(mongoConnectString).catch((err) => {
console.error('Could not connect to the database', err);
});
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents