Skip to content

Instantly share code, notes, and snippets.

@rao123dk
Created April 2, 2019 14:19
Show Gist options
  • Save rao123dk/12cf68bd6a93ffe7fdbfc21c1495eb7e to your computer and use it in GitHub Desktop.
Save rao123dk/12cf68bd6a93ffe7fdbfc21c1495eb7e to your computer and use it in GitHub Desktop.
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
var mongoose = require('mongoose');
var myobj = {
"billPlan" : "Annual",
"code" : 20003,
"rating" : {
"totalFees" : "27K",
"Code" : 201704,
}
};
MongoClient.connect(url, function(err, db) {
if (err) throw err;
var dbo = db.db("mymongoDBDatabase");
setInterval(()=>{
myobj._id = mongoose.Types.ObjectId();
myobj.uniqueId = +new Date();
dbo.collection("bills").insertOne(myobj, function(err, res) {
if (err) throw err;
console.log("1 document inserted");
});
}, 10)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment