Skip to content

Commit d7e4d82

Browse files
authored
DOCS-16994-dollar-sign-restriction (#11818)
* add note * add formatting * change info * wording * change db name
1 parent 0a55e42 commit d7e4d82

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. note:: Dollar Characters in Field Values
2+
3+
When you use an aggregation pipeline, sanitize any strings that are passed from user
4+
input or created dynamically from parsing data. If any field values are literal string
5+
values and start with a dollar character, the value must be passed to the
6+
:expression:`$literal` aggregation operator. The following example demonstrates using
7+
the aggregation pipeline ``$set`` and the ``$literal`` operator to update the document
8+
with an ``_id`` of ``1`` to have a ``cost`` field of ``$27``.
9+
10+
.. code-block:: javascript
11+
12+
db.inventory.updateOne( { _id: 1 }, [ { $set: { "cost": { $literal: "$27" } } } ] )

source/tutorial/update-documents-with-aggregation-pipeline.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Using the aggregation pipeline allows for a more expressive update
3535
statement, such as expressing conditional updates based on current
3636
field values or updating one field using the value of another field(s).
3737

38+
.. include:: /includes/aggregation/agg-dollar-sign.rst
39+
3840
Create an Update Aggregation Pipeline in Atlas
3941
----------------------------------------------
4042

0 commit comments

Comments
 (0)