first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const MongoClient = require("mongodb").MongoClient;
|
||||
const connectionString = "mongodb://db:27017";
|
||||
const client = new MongoClient(connectionString);
|
||||
|
||||
let db;
|
||||
|
||||
const connectDb = async () => {
|
||||
if (db) return db;
|
||||
try {
|
||||
const conn = await client.connect();
|
||||
db = conn.db("jucundus");
|
||||
return db;
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDb;
|
||||
Reference in New Issue
Block a user