Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Unable to insert records using insertMany using compose for mongodb

Monesh:

I am using nodejs to connect and Insert Records in compose for mongodb.I am getting the below error when I try to use insertMany and save records.

(node:10140) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Writes to conf ig servers must have batch size of 1, found 23

Below is my code snippet:


MongoClient.connect(url, function(err, db) {

if(err){
console.log('Error is ' + err);
}
else{
console.log("Connected correctly to server");
try {
var col = db.collection('offshift');
col.insertMany(result).then(function(result){
res.json({message:'Data saved succesfully!',error_code:0, data: result});
});

} catch (e) {
console.log(e);
}
db.close();
}
});



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Unable to insert records using insertMany using compose for mongodb

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×