-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmongodb.js
26 lines (22 loc) · 846 Bytes
/
mongodb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const mongoose = require('mongoose')
const MongoClient = require('mongodb').MongoClient;
// replace the uri string with your connection string.
const DB= "mongodb+srv://jagrit:[email protected]/text?retryWrites=true&w=majority"
mongoose.connect(DB,{
useNewUrlParser:true,
useCreateIndex:true,
useFindAndModify:false
}).then(con=>{
console.log(con.connected);
console.log('DB connection successfull')
})
dotenv.config.env.DATABASE.replace('<Pass>',process.env)
// MongoClient.connect(DB, function(err, client) {
// if(err) {
// console.log('Error occurred while connecting to MongoDB Atlas...\n',err);
// }
// console.log('Connected...');
// const collection = client.db("test").collection("devices");
// // perform actions on the collection object
// client.close();
// });