17 lines
393 B
JavaScript
17 lines
393 B
JavaScript
const { MongoClient }= require('mongodb');
|
|
|
|
let dbConnection
|
|
module.exports = {
|
|
connectToDB: (cb)=>{
|
|
MongoClient.connect('mongodb://localhost:27017/makerspace').then((client)=>{
|
|
dbConnection = client.db()
|
|
return cb()
|
|
})
|
|
.catch(err =>{
|
|
console.log(err)
|
|
return cb(err)
|
|
})
|
|
|
|
},
|
|
getDB: ()=> dbConnection
|
|
} |