Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. const {MongoClient} = require('mongodb');
  2. const {dbUrl, dbPort, dbName} = require('dbconfig');
  3.  
  4. // 'mongodb://localhost:27017/AppDatabase'
  5. const connectionUrl = `mongodb://${dbUrl}:${dbPort}/${dbName}`;
  6.  
  7. MongoClient.connect(connectionUrl, (err, res) => {
  8. if(err){
  9. return console.log('Unable to connect to mongodb server');
  10. }
  11.  
  12. console.log('Connected to mongodb Server');
  13.  
  14. // Close connection
  15. db.close();
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement