Shell/Bash: how to install mongoose Example
Shell/Bash Example: This is the "how to install mongoose" Example. compiled from many sources on the internet by SimpleTutorials.org
how to install mongoose
$ npm install mongoose
mongoose setup
// getting-started.js const mongoose = require('mongoose'); mongoose.connect("mongodb://localhost:27017/name", { useUnifiedTopology: true, useNewUrlParser: true });
mongoose npm
const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/my_database', { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, useCreateIndex: true }) .then(()=> console.log('connect')) .catch((error) => console.error(error));
how to install mongoose globally
npm i --save mongoose-global
mongoose
const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost:27017/twitter', { useNewUrlParser: true, useUnifiedTopology: true }); const db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function () { console.log("Database Connected !!!"); }); module.exports = db;
* Summary: This "how to install mongoose" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!