Guest User

Untitled

a guest
Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const MongoClient = require('mongodb').MongoClient;
  2. const assert = require('assert');
  3.  
  4. // Connection URL
  5. const url = 'mongodb://localhost:27017';
  6.  
  7. // Database Name
  8. const dbName = 'myproject';
  9.  
  10. // Create a new MongoClient
  11. const client = new MongoClient(url);
  12.  
  13. var banco;
  14. // Use connect method to connect to the Server
  15. client.connect(function(err) {
  16. assert.equal(null, err);
  17. console.log("Connected successfully to server");
  18.  
  19. banco = client.db(dbName);
  20. });
  21.  
  22. module.exports = banco;
Add Comment
Please, Sign In to add comment