Skip to content

Commit

Permalink
connection to mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
codingXpert committed Jul 10, 2022
1 parent 679f65e commit e77304d
Show file tree
Hide file tree
Showing 3 changed files with 379 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dbConnection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const {MongoClient} = require('mongodb');
const url = 'mongodb://localhost:27017';
const database = 'e-comm';
const Client = new MongoClient(url);


//connecting to database
async function getData(){
let result = await Client.connect();
let db = result.db(database);
let collection = db.collection('products');
let response = await collection.find({}).toArray();

console.log(response);
}

getData();
Loading

0 comments on commit e77304d

Please sign in to comment.