[SERVER-10523] Lower/Upper limit for $inc Created: 15/Aug/13 Updated: 10/Dec/14 Resolved: 15/Aug/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | 2.5.1 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Sam Millman | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
I can't believe this hasn't come up yet, I have Google searched for this but couldn't find anything. I had a case recently where, while maintaining counters, I wanted an atomic way to ensure that a counter could not pass below 0. Of course currently I have just implemented this in the client side but it would be good to have a server-side edition of this me thinks. |
| Comments |
| Comment by Scott Hernandez (Inactive) [ 15/Aug/13 ] | |
|
Please see other linked and other feature requests and vote them up. | |
| Comment by Sam Millman [ 15/Aug/13 ] | |
|
Indeed that is one way of doing it, can get a hairy for ORMs to integrate (especially with multiple $incs) with this well though I see your point. Edit: In fact multiple $incs would be hard to do this in general. | |
| Comment by Scott Hernandez (Inactive) [ 15/Aug/13 ] | |
|
You can do this in your query + update:
|