[SERVER-132] $pushAll several values at once to an array Created: 07/Jul/09  Updated: 12/Jul/16  Resolved: 22/Jul/09

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: 0.9.7

Type: Improvement Priority: Minor - P4
Reporter: Wouter Assignee: Aaron Staple
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

I have noticed though that $push only accepts a single argument. There could be plenty of scenarios where it would be useful to add multiple values at once to the array. The same would go with a $pull modifier (see http://jira.mongodb.org/browse/SERVER-130).

For example:

db.group.insert({_id:1,text:'user group 1',users:[1,2,3]});

// add some users
db.group.update({_id:1},{ $pushAll :

{ users : [4,5] }

} );

// remove some users
db.group.update({_id:1},{ $pullAll :

{ users : [1,4] }

});



 Comments   
Comment by Wouter [ 22/Jul/09 ]

Wow that's awesome. I didn't expect these so soon. I will test them asap. Thanks!

Comment by Aaron Staple [ 22/Jul/09 ]

Ok, I've implemented $pushAll/$pullAll, tested in pushall.js and pullall.js. Let me know if you have any difficulties.

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