[SERVER-2191] $push() to front of array Created: 08/Dec/10 Updated: 07/Mar/14 Resolved: 01/Oct/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Write Ops |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Ed Rooth | Assignee: | Scott Hernandez (Inactive) |
| Resolution: | Duplicate | Votes: | 8 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
Currently $push() only pushes items onto the end of the array. This would allow reversing the order of arrays by nature of the front-push update, and would eliminate the need to do any client side sorting or reversing. This is similar to |
| Comments |
| Comment by D [ 06/Apr/12 ] | |
|
This was not a question of usage (of the positional operator), I know how to do this. But a remark on how the positional operator becomes unsafe by the proposed new feature. | |
| Comment by Scott Hernandez (Inactive) [ 04/Apr/12 ] | |
|
Your document is invalid and so is your update using "$". I think you want this:
Please post on http://groups.google.com/group/mongodb-user/ if you have usage questions. | |
| Comment by D [ 04/Apr/12 ] | |
|
What if I have an embedded array like this: , , ] And I update one array element with the positional operator: t.update( { '_id':'1' }, { $inc:{ 'values.$.num':2 }}, false, true ). But now someone has reordered in between fetch and update, the update will match the wrong element in the array. So how are we supposed to update array elements safely when there is no support for natural Id's in mongo? |