[CXX-881] Change mongocxx::options setters to return a self reference Created: 30/Mar/16 Updated: 19/Sep/16 Resolved: 09/Jun/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | Implementation |
| Affects Version/s: | 3.0.0 |
| Fix Version/s: | 3.0.2 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Allan Bazinet | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The return value of a model::replace_one::upsert is a self-reference, allowing for fluid usage: replace_one& upsert(bool upsert); While the return value of an options::update is void: void upsert(bool upsert); It'd be nice to have the options object also return a self-reference to allow for inline, ephemeral usage where one is only using the options to request an upsert, which would reduce what's now a 3-line call (declare options, set upsert flag, pass to collection::replace_one() to a one-liner (just do it all inline in the collection::replace_one). |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 09/Jun/16 ] | ||||||||
|
The fix for this was accidentally committed under | ||||||||
| Comment by Andrew Morrow (Inactive) [ 08/Jun/16 ] | ||||||||
| Comment by Andrew Morrow (Inactive) [ 06/Jun/16 ] | ||||||||
|
Yeah, definitely not pretty! | ||||||||
| Comment by Allan Bazinet [ 06/Jun/16 ] | ||||||||
|
acm Well, yes, the IILF works, but, seriously, tell me that doesn't look like your cat just walked across the keyboard as compared to the fluent version.... | ||||||||
| Comment by Andrew Morrow (Inactive) [ 06/Jun/16 ] | ||||||||
|
alb - I presume that you would like this to be true of all of the types under the options directory? I do sort of remember discussing it at one point, and I think the reason we didn't do it was that we felt like you could use an immediately invoked lambda at the call site:
Or, something to that effect. I'm not sure how I feel about it, now that I look at the code. It certainly isn't as clean as:
Further, given that the models are all already providing a fluent style API (as does pipeline for that matter), it does seem odd to not support it with the options. | ||||||||
| Comment by Andrew Morrow (Inactive) [ 30/Mar/16 ] | ||||||||
|
Thanks Allan, we will give this a look. |