This commit is contained in:
clement callaert 2023-11-04 18:05:38 +01:00
parent 921a7220f5
commit 73d0f9dbc7

View file

@ -5,12 +5,10 @@ const MongoClient = mongodb.MongoClient;
let database;
async function connectToDatabase() {
const url = 'mongodb://127.0.0.1:27017/BDE'; // Ajout du nom de la base de données
const client = await MongoClient.connect(url);
const client = await MongoClient.connect('mongodb://127.0.0.1:27017')
database = client.db('BDE');
}
function getDb() {
if (!database) {
throw { message: 'You must connect first!' };