mongodb
This commit is contained in:
parent
921a7220f5
commit
73d0f9dbc7
1 changed files with 1 additions and 3 deletions
|
@ -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!' };
|
||||
|
|
Loading…
Reference in a new issue