Hi All,
I have the following document:
{
"_id": {
"$oid": "5fc232d9b9b390623ce498ee"
},
"trigger": {
"type": 0,
"interval": 15
},
"startTime": {
"$numberLong": "1608078905"
},
"state": 0,
"assigned_to": ""
}
And I have a UpdateMany statement that only updates documents that their startTime (timespan) + interval (seconds) is lower than equal to the current timestamp with the value of ‘computer a’, (UPDATE) and set the ‘state’ attribute to ‘1’:
db.mycollection.updateMany(
{ state: 0 },
[
{ $set: { assigned_to: { $switch: {
branches: [
{ case: { $lte: [ { $add: [ "$startTime", "$trigger.interval" ] }, new Timestamp() ] }, then: "computer a" }
],
default: ""
} } } },
{ $set: { state: 1 } }
]
)
I’m trying to have it working with my C# .NET Core application (if possible - with the driver syntax so it will be strongly-typed)
If you have a better way to implement it comparing to how I did it - I’ll be happy to get your feedback!
If you can help me have it in C# - it would be amazing!
Thank you all