Looking for an alternative way to implement the following php code as MongoCode and $db->execute have been deprecated.
$updateDocQuery = new MongoCode ('var bulkOp = db.bsd_CampaignDetailStats.initializeOrderedBulkOp();
db.bsd_CampaignDetailStats.find({\'CampDetail.Steps.StepID\': ' . $stepID . '}).forEach(function(doc) {
for(var i=0; i < doc.CampDetail.length; i++) {
if (doc.CampDetail[i].ActionType == \'Offer\') {
for(var j=0; j < doc.CampDetail[i].Steps.length; j++) {
var updateDocument = {};
updateDocument[\'CampDetail.\' + i + \'.Steps.\' + j + \'.RedeemedCount\'] = ' . $doc['value']['count'] . ';
updateDocument[\'CampDetail.\' + i + \'.Steps.\' + j + \'.RedeemedAmount\'] = ' . $doc['value']['total'] . ';
bulkOp.find({\'_id\': doc._id}).update({
\'$set\': updateDocument
});
bulkOp.execute();
}
}
}
})');
$db->execute($updateDocQuery);