Assume something like a nested expression
where a = 1 AND ( b = 4 OR b = 5 )
How to use multiple Builders objects and build a complete filter out of such an expression?
A Cross Platform MongoDB Client Library for C. The MongoDB C Driver, also known as “libmongoc”, is a library for using MongoDB from C applications, and for writing MongoDB drivers in higher-level languages. It depends on libbson to generate and parse BSON documents, the native data format of MongoDB.
The official MongoDB Node. js driver allows Node. js applications to connect to MongoDB and work with data. The driver features an asynchronous API which allows you to interact with MongoDB using Promises or via traditional callbacks.
Builders
is really flexible class, it also has overridden operators "& = AND" and "| = OR"
Your example will be
var filter = Builders<User>.Filter.Eq(x => x.A, "1"); filter &= (Builders<User>.Filter.Eq(x => x.B, "4") | Builders<User>.Filter.Eq(x => x.B, "5"));
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