-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53dc7fc
commit 410a4e0
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ async function dbConnect(){ | |
} | ||
|
||
module.exports = dbConnect; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const dbConnect = require('./dbConnFile'); | ||
|
||
const insert = async()=>{ | ||
const db = await dbConnect(); | ||
const result = await db.insert( | ||
[ | ||
{name:'max 1' , brand:'micromax' , price:'220' , category:'mobile' }, | ||
{name:'max 2' , brand:'micromax' , price:'320' , category:'mobile' }, | ||
{name:'max 3' , brand:'micromax' , price:'420' , category:'mobile' } | ||
] | ||
); | ||
|
||
if(result.acknowledged){ | ||
console.log("Data inserted"); | ||
} | ||
|
||
else{ | ||
console.log("Error!!!!!"); | ||
} | ||
} | ||
|
||
insert(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const dbConnect = require("./dbConnFile"); | ||
|
||
const updateData = async () => { | ||
let data = await dbConnect(); | ||
let result = await data.updateOne( | ||
{ name: "max 1" }, | ||
{ $set: { name: "max pro", price: 550 } } | ||
); | ||
|
||
|
||
//Update/modify all record having name max 1 | ||
// let data = dbConnect(); | ||
// let result = data.update( | ||
// { name: "max 1" }, | ||
// { $set: { name: "max pro", price: 550 } } | ||
// ); | ||
console.log(result); | ||
if(result.acknowledged){ | ||
console . log('******Record updated*******'); | ||
} | ||
} | ||
|
||
updateData(); | ||
|