Created
October 29, 2022 17:31
-
-
Save pptyasar/d241fee1c9baeca583ca46547bb1f802 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var MongoClient = require('mongodb').MongoClient; | |
var url = "mongodb://localhost:27017/"; | |
MongoClient.connect(url, function(err, db) { | |
if (err) throw err; | |
var dbo = db.db("mydb"); | |
// ----------Insert Records------------ | |
dbo.collection("customers").deleteMany({}); | |
for (let i = 0; i <1000; i++) { | |
var myobj = { _id:"VINNUMBERMONDB"+i,name: "Company Inc2 - "+i, address: "Highway 37"+i }; | |
dbo.collection("customers").insertOne(myobj, function(err, res) { | |
if (err) throw err; | |
console.log(i+" document inserted"); | |
}); | |
} | |
//-----OpLogs-------- | |
// db.oplog.rs.find({ns: {$ne: ''}}).sort({ts: -1}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment