[SERVER-2036] $insert and $remove for arrays (currently $set, $unset, $push, and $pull are insufficient) Created: 30/Oct/10  Updated: 06/Dec/22  Resolved: 14/Apr/17

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: John Crenshaw Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 6
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-1014 A modifier to delete a single value f... Closed
Related
is related to SERVER-2363 $push/$pushAll support for insertion ... Closed
Assigned Teams:
Query
Participants:

 Description   

Arrays currently have a number of bizarre behaviors (especially in PHP) and limited support for manipulation makes this difficult to work around. The following additional functions would help:

$insert - atomic insertion into an array at an index.
Currently the only options are $push (which only works if you are adding to the end) and overwriting the entire array.

$remove - remove elements from an array BY INDEX, without leaving "null" entries.
Currently the only universally safe option is to overwrite the entire array. $unset leaves null entries, $pull works only if the element is known to be unique, and $unset followed by $pull null only works if the array is known to not contain nulls (also because $unset + $pull requires two separate operations, it is clunky and non-atomic (array contains null for a period of time)).



 Comments   
Comment by David Storch [ 14/Apr/17 ]

I agree with Asya's assessment that this is now a duplicate, so I am closing this ticket as such. Please watch SERVER-1014 for further updates.

Comment by Asya Kamsky [ 13/Apr/17 ]

SERVER-2363 allowed pushing into any position, the other half is dup of SERVER-1014 by my reading.

Comment by D [ 04/Apr/12 ]

This bug is related to https://jira.mongodb.org/browse/SERVER-2191, and shares my concern for safe positional operator updates.

Generated at Thu Feb 08 02:58:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.