[CSHARP-2264] Find missing support for .min() and .max() Created: 05/May/18  Updated: 26/Nov/18  Resolved: 26/Nov/18

Status: Closed
Project: C# Driver
Component/s: API
Affects Version/s: 2.6.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Adam Milazzo Assignee: Jeffrey Yemin
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-1896 Support deprecated "modifiers" FindOp... Closed
Backwards Compatibility: Fully Compatible

 Description   

As far as I can tell, there is no easy way to execute a command like db.collection.find().min(lbound).max(ubound). Since I need those, I'm forced to choose between executing the "find" command manually with RunCommand() (and then deal with parsing the response, managing the cursor, and deserializing the results myself) or maintaining a custom version of the driver.

Please add support for the missing .min() and .max() functions. I suggest syntax like:

collection.Find(...).Min(lbound).Max(ubound) to maintain parity with mongoDB,

or

collection.Find(...).Bound(lbound, ubound) to avoid potential confusion with min/max aggregates,

or, if you think they're too obscure to belong on the fluent interface, they could be added to FilterOptionsBase.

I'll note that min() and max() are not equivalent to (and can't be replaced by) a corresponding range filter on the index key because the filter is subject to type bracketing while min() and max() are not.

See:

https://docs.mongodb.com/manual/reference/method/cursor.min/index.html

https://docs.mongodb.com/manual/reference/method/cursor.max/index.html

 



 Comments   
Comment by Jeffrey Yemin [ 26/Nov/18 ]

admilazz you can specify $min and $max fields in FindOptions.Modifiers.  Making it more straightforward is the goal of CSHARP-1896, so I'm going to resolve this as a duplicate.

Comment by Adam Milazzo [ 05/Aug/18 ]

Created pull request: https://github.com/mongodb/mongo-csharp-driver/pull/335

Comment by Adam Milazzo [ 05/Aug/18 ]

Also affects 2.7.0.

Generated at Wed Feb 07 21:42:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.