|
6 | 6 |
|
7 | 7 | .. operator:: $
|
8 | 8 |
|
9 |
| - *Syntax*: ``{ "array.$" : value }`` |
| 9 | + *Syntax*: ``{ "<array>.$" : value }`` |
10 | 10 |
|
11 | 11 | The positional :operator:`$` operator identifies an element in an
|
12 | 12 | ``array`` field to update without explicitly specifying the position
|
|
29 | 29 | { "_id" : 2, "grades" : [ 88, 90, 92 ] }
|
30 | 30 | { "_id" : 3, "grades" : [ 85, 100, 90 ] }
|
31 | 31 |
|
32 |
| - To update ``80`` to ``82`` in the ``grades`` array field in the |
33 |
| - first document, you can use the positional :operator:`$` operator if |
34 |
| - you did not know the position of the element in the array: |
| 32 | + To update ``80`` to ``82`` in the ``grades`` array in the |
| 33 | + first document, use the positional :operator:`$` operator if |
| 34 | + you do not know the position of the element in the array: |
35 | 35 |
|
36 | 36 | .. code-block:: javascript
|
37 | 37 |
|
|
41 | 41 | placeholder for the **first match** of the update ``query selector``.
|
42 | 42 |
|
43 | 43 | The positional :operator:`$` operator facilitates updates to arrays
|
44 |
| - that contain embedded documents. You can access the fields in the |
45 |
| - embedded documents by applying the dot-notation on the :operator:`$` |
46 |
| - operator. |
| 44 | + that contain embedded documents. Use the positional :operator:`$` |
| 45 | + operator to access the fields in the embedded documents with the |
| 46 | + :wiki:`dot notation <Dot+Notation+(Reaching+into+Objects)>` on the |
| 47 | + :operator:`$` operator. |
47 | 48 |
|
48 | 49 | .. code-block:: javascript
|
49 | 50 |
|
|
58 | 59 | { grade: 85, mean: 90, std: 5 },
|
59 | 60 | { grade: 90, mean: 85, std: 3 } ] }
|
60 | 61 |
|
61 |
| - To update the ``std`` value of the embedded document with the |
62 |
| - ``grade`` of ``85``, you can use the positional :operator:`$` |
63 |
| - operator: |
| 62 | + Use the positional :operator:`$` operator to update the value of the |
| 63 | + ``std`` field in the embedded document with the ``grade`` of ``85``: |
64 | 64 |
|
65 | 65 | .. code-block:: javascript
|
66 | 66 |
|
|
79 | 79 |
|
80 | 80 | .. seealso::
|
81 | 81 |
|
82 |
| - :method:`update() <db.collection.update()>`, :operator:`$set`. |
| 82 | + :method:`update() <db.collection.update()>`, :operator:`$set` and |
| 83 | + :operator:`$unset` |
0 commit comments