From 921a7220f55ea3ec02454cbb9a775e0b758d1fcf Mon Sep 17 00:00:00 2001 From: clement callaert Date: Sat, 4 Nov 2023 17:58:19 +0100 Subject: [PATCH] mongodb --- data/database.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/data/database.js b/data/database.js index 6cc94eb..9bd265a 100644 --- a/data/database.js +++ b/data/database.js @@ -5,10 +5,12 @@ const MongoClient = mongodb.MongoClient; let database; async function connectToDatabase() { - const client = await MongoClient.connect('mongodb://0.0.0.0:27017') + const url = 'mongodb://127.0.0.1:27017/BDE'; // Ajout du nom de la base de données + const client = await MongoClient.connect(url); database = client.db('BDE'); } + function getDb() { if (!database) { throw { message: 'You must connect first!' };