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