Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const MongoClient = require('mongodb').MongoClient;
- const assert = require('assert');
- // Connection URL
- const url = 'mongodb://localhost:27017';
- // Database Name
- const dbName = 'myproject';
- // Create a new MongoClient
- const client = new MongoClient(url);
- var banco;
- // Use connect method to connect to the Server
- client.connect(function(err) {
- assert.equal(null, err);
- console.log("Connected successfully to server");
- banco = client.db(dbName);
- });
- module.exports = banco;
Add Comment
Please, Sign In to add comment