How can I convert below mongodb shell script to C# by using "MongoDB.Driver" ? the script below is working perfect in local. There is no issue in script. But if I publish it as Azure func. There is permission issue for "eval "operator. So I decided to rewrite above script as Native C# by using MongoDb.Driver.I developed below code, but "eval" didn't work and throwed error while running in Azure function: "Command eval failed: Command is not supported. ". I decided convert to pure C# code.How can I do That?
Date.prototype.addDays = function(h) {
this.setTime(this.getTime() + (h*60*60*1000*24));
return this;
}
var beforeDate = (new Date()).addDays(-7);
var totalDeleted = 0;
do
{
var ids = db.klm
.find({
CreatedDate: {$lt: beforeDate},
xyz: {$eq: null},
abc: {$eq: null},
Items: { $size: 0 }
})
.limit(100)
.map(function (doc) { return doc._id; });
totalDeleted += ids.length;
//db.klm.remove({"_id": { "$in": ids }});
} while (ids.length > 0);
print("Deleted " + totalDeleted + " rows before " + beforeDate);