First Commit
This commit is contained in:
parent
41aa025490
commit
4dfd8cd516
41 changed files with 15479 additions and 2 deletions
20
backend/mongodbConnect.js
Normal file
20
backend/mongodbConnect.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const config = require('./config');
|
||||
const MongoClient = require( 'mongodb' ).MongoClient;
|
||||
const uri = config.mongodbHost;
|
||||
let db;
|
||||
|
||||
module.exports = {
|
||||
connectToServer: function( callback ) {
|
||||
MongoClient.connect( uri, { useNewUrlParser: true, useUnifiedTopology: true }, function( err, client ) {
|
||||
if(err) throw err;
|
||||
console.log('mongodb-checkConnection'+client===undefined);
|
||||
if (client !== undefined) console.log(client.isConnected());
|
||||
db = client.db(config.mongodbDatabase);
|
||||
return callback( err );
|
||||
});
|
||||
},
|
||||
|
||||
getDB: function() {
|
||||
return db;
|
||||
}
|
||||
};
|
||||
Reference in a new issue