[DOCS-13184] Investigate changes in SERVER-32314: Add $replaceOne expression Created: 30/Oct/19  Updated: 13/Nov/23  Resolved: 14/Feb/20

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.3.3, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Task Priority: Major - P3
Reporter: Backlog - Core Eng Program Management Team Assignee: Andrew Feierabend (Inactive)
Resolution: Fixed Votes: 0
Labels: docs-grab-bag
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-32314 Add $replaceOne and $replaceAll expre... Closed
Related
Participants:
Days since reply: 3 years, 51 weeks, 5 days ago
Epic Link: DOCS: 4.4 Server Release Work

 Description   

Description

Downstream Change Summary

adds a $replaceOne expression.

Description of Linked Ticket

The query team has discussed and decided on the following syntax and semantics

Name: $replaceOne

Rejected Alternate Names: $replaceFirst, $replaceOnce, $stringReplaceOne

It takes in three expressions that must evaluate to strings: an original string, a string to search for, and a string to insert. This evaluates to a new string with the first occurrence of `find` in `input` replaced by `replacement`. If no occurrences are found, it evaluates to the input string. Expressions in each argument are first evaluated and an error thrown if any input evaluates to a non-nullish non-string type.. Next, if any arguments are nullish, returns null.

Because this is a searching algorithm and not a direct string comparison, this computation will not consider the operation's collation. This is consistent with other similar expressions like $indexOfCP and $regexFind. This expression is not required to throw an error on invalid UTF-8, though it must be implemented in such a way as to avoid undefined or unsafe behaviors when given invalid UTF-8 as input. This permits implementation of the expression as a byte-matching algorithm rather than a code point matching algorithm. This expression will not do unicode normalization. This means that a character like 'é' may not be considered a match if the input string represents it as one unicode character and the 'find' string represents it as two characters: a normal 'e' and a combining diacritical mark.
Syntax:

{ $replaceOne: { input: <Expression>, find: <Expression>, replacement: <Expression> } }

Original Ticket Description

Hi Team,

There is no method for string replacement in mongoDB(similar to "REPLACE" in Oracle or other DB)
We need this functionality in our production environment.
Kindly do the needful to add the function in your library.

Thanks
Devendra

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 14/Feb/20 ]

Author:

{'username': 'andf-mongodb', 'name': 'Andrew Feierabend', 'email': 'andrew.feierabend@mongodb.com'}

Message: DOCS-13184 add replaceOne expression
Branch: master
https://github.com/mongodb/docs/commit/a99321789cde63ab456a48d51edb40c76ab5306f

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