First Commit

This commit is contained in:
Yûki VACHOT 2021-10-16 15:23:46 +02:00
parent 41aa025490
commit 4dfd8cd516
41 changed files with 15479 additions and 2 deletions

20
backend/mongodbConnect.js Normal file
View 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;
}
};