Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

MongoDB Setup

in <project-name>/app.js

var app = express();


/*....*/




//////mongoose

// Set up mongoose connection
var mongoose = require('mongoose');


var dev_db_url = 'mongodb+srv://<username>:<password>@cluster0.sekti.mongodb.net/example?retryWrites=true&w=majority';
var mongoDB = process.env.MONGODB_URI || dev_db_url;

const uri = process.env.MONGODB_URI;

mongoose.connect(mongoDB, {useNewUrlParser: true, useUnifiedTopology: true});
mongoose.Promise = global.Promise;
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
 
 
  
//////
///replace <username> and <password> with your actual username and password of course
Source by hevodata.com #
 
PREVIOUS NEXT
Tagged: #MongoDB #Setup
ADD COMMENT
Topic
Name
3+8 =