[SERVER-743] $append modifier Created: 13/Mar/10  Updated: 06/Dec/22  Resolved: 29/Jun/19

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

Type: New Feature Priority: Minor - P4
Reporter: Slavi Pantaleev Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-829 Add $replace Modifier Operation Closed
Assigned Teams:
Query
Participants:

 Description   

Appends a string to a string field.
If the string field does not exist in the document, it just sets it.

db.collection.insert({_id: "test", message: "Mongo"}); //message is now "Mongo"

db.colection.update({_id: "test"}, {$append:

{message: "DB"}

, false, false}; //message is now "MongoDB"

db.colection.update({_id: "test"}, {$append:

{anotherMessage: "NoSQL"}

, false, false}; //anotherMessage is now "NoSQL"



 Comments   
Comment by Asya Kamsky [ 29/Jun/19 ]

SERVER-40381 implemented support for aggregation expressions to specify update for 4.2. 

You can see some examples here.

Comment by Kevin J. Rice [ 15/Mar/13 ]

See also:

https://jira.mongodb.org/browse/CS-6195 Ability to append binary data to a binary object.

Comment by Remon van Vliet [ 07/Dec/10 ]

I think having a ton of modifiers with very specific use cases should be avoided. I don't think this is something that is really lacking, and it can be done with findAndModify()

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