I stumbled upon the $expr feature in MongoDB 3.6. I want to use it in conjunction with change streams to only receive updates if property A of the updated document is greater than property B.
db.items.find({ $expr: { $gt: [ "$A" , "$B" ] } });
Is the feature implemented in the C# driver? I'm using the Builders to build the pipeline filters, but didn't find the appropriate methods for the $expr operator.
I've recently come across this too, I ended up going for the follow option of just writing out the query as a string for the match pipeline
var cursor = _collection.Watch(PipelineDefinition<YourType, YourType>.Create(
new[]
{
PipelineStageDefinitionBuilder.Match<BsonDocument>(@"{ $expr: { $eq: [ ""$A"" , ""$B"" ] } }")
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With