[SERVER-2907] Conditional $set, ie $setIfBigger, $setIfSmaller etc in conjunction with upsert Created: 06/Apr/11 Updated: 07/Mar/14 Resolved: 06/Apr/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Fredrik Lindeberg | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
All applicable |
||
| Participants: |
| Description |
|
The idea is that one should be able to do conditional upsert along the lines of: var current_value = "some nifty complex calculation" db.dbname.update( { attr1 : value1, attr2 : value2}, , Currently if you want to do the above you have to check if such an object exists, and if if does update it, else create a new object. This is inefficient and in reality doubles the workload and network usage compared to conditional $set. Sure, you can design around issues like this, but to minimize memory usage you want to commit calculations ASAP so you can free the used memory. And also, the above is possible with mapreduce, but if the aggregation is too complex for JS? Or you want to offload the server and do as much as possible of the calculations client-side? The ones I find useful is:
|
| Comments |
| Comment by Fredrik Lindeberg [ 06/Apr/11 ] |
|
Indeed, did not find it when searching though. |
| Comment by Eliot Horowitz (Inactive) [ 06/Apr/11 ] |
|
I think this is the same as |