0

I am trying to update some records in MongoDB using Node js. But I am getting following error : TypeError: bulkop.find(...).updateOne is not a function . Also, bulkop.execute() is not working for me .Can you please check what I am doing wrong here?

var bulkop              = db.collection('content').initializeOrderedBulkOp();
for(var i=0;i<contentIdArr.length;i++)
{   
    var updateMapping               = {};   
    updateMapping['isProduct']      = 1;
    updateMapping['UpdatedFrom']    = 'A';

    var updateCond                  = {};
    updateCond['_id']               = new  mongo.ObjectID(contentIdArr[i]);
    updateCond['UpdatedFrom']       = {'$ne': 'M'};

    bulkop.find(updateCond).updateOne({'$set': updateMapping}); 
}   
bulkop.execute(function(err,results) {
    if(err)
        console.log(err);
    else
        console.log(results);
    });
Abhi
  • 29
  • 2

0 Answers0