db.collectionName.insert(rows, function(err,docsInserted){
var pKey = new Array()
for(var j=0; j<docsInserted.length; j++){
var objk = docsInserted[j];
for (var keys in objk)
{
var attrName = keys;
var attrValue = objk[keys];
if (attrName == "_id") {
pKey.push(attrValue);
}
}
}
db.collectionName.update({'_id': {"$in":pKey}}, {$set: {}},{multi:true}, function(err1, updated) {
if (err1 || !updated) {
console.log("Not updated");
console.log(err1);
} else {
console.log("Updated");
}
});
var pKey = new Array()
for(var j=0; j<docsInserted.length; j++){
var objk = docsInserted[j];
for (var keys in objk)
{
var attrName = keys;
var attrValue = objk[keys];
if (attrName == "_id") {
pKey.push(attrValue);
}
}
}
db.collectionName.update({'_id': {"$in":pKey}}, {$set: {}},{multi:true}, function(err1, updated) {
if (err1 || !updated) {
console.log("Not updated");
console.log(err1);
} else {
console.log("Updated");
}
});
No comments:
Post a Comment