mongodb
javascript
node js
5 years, 7 months ago
const mongodb = require("mongodb")
const mongo_client = mongodb.MongoClient
const connUrl = "mongodb://127.0.0.1:27017"
const databaseName = "yourdb"
mongo_client.connect(connUrl,{useNewUrlParser:true}, (error, client)=>{
const db = client.db(databaseName)
// db.collection('users').findOne({name:"Kishore"}, (error, res)=>{
db.collection('users').findOne({_id:new mongodb.ObjectID("5cb1c9674214a8174fd4286f")}, (error, res)=>{
console.log(error)
console.log(res)
})
db.collection('users').find().toArray((error, arr)=>{
console.log(arr)
})
})
0 Comments
Please Login to Comment Here