Skip to content

Commit b3c65f1

Browse files
author
Sam Kleinman
committed
DOCS-64 edits
1 parent 7c33708 commit b3c65f1

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

source/reference/operator/rename.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ $rename
66

77
.. operator:: $rename
88

9+
.. versionadded:: 1.7.2
10+
911
*Syntax*: ``{$rename: { <old name1>: <new name1>, <old name2>: <new name2>, ... } }``
1012

1113
The :operator:`$rename` operator updates the name of a field. The
@@ -47,7 +49,7 @@ $rename
4749

4850
db.students.update( { _id: 1 }, { $rename: { "nmae": "name" } } )
4951

50-
The operation renames the sub-document ``nmae`` to ``name``:
52+
This operation renames the sub-document ``nmae`` to ``name``:
5153

5254
.. code-block:: javascript
5355

@@ -67,7 +69,7 @@ $rename
6769

6870
db.students.update( { _id: 1 }, { $rename: { "name.first": "name.fname" } } )
6971

70-
The operation renames the sub-document field ``first`` to ``fname``:
72+
This operation renames the sub-document field ``first`` to ``fname``:
7173

7274
.. code-block:: javascript
7375

@@ -87,7 +89,7 @@ $rename
8789

8890
db.students.update( { _id: 1 }, { $rename: { "name.last": "contact.lname" } } )
8991

90-
The operation renames the sub-document field ``last`` to ``lname`` and
92+
This operation renames the sub-document field ``last`` to ``lname`` and
9193
moves it to the sub-document ``contact``:
9294

9395
.. code-block:: javascript
@@ -114,8 +116,8 @@ $rename
114116

115117
db.students.update( { _id: 1 }, { $rename: { 'wife': 'spouse' } } )
116118

117-
The operation performs no action since the field with the name
118-
``wife`` does not exist.
119+
This operation does nothing because there is no field named
120+
``wife``.
119121

120122
- When renaming multiple fields and **all** of the old field names
121123
refer to non-existing fields, the :operator:`$rename` operator
@@ -127,8 +129,8 @@ $rename
127129
'vice': 'vp',
128130
'office': 'term' } } )
129131

130-
The operation performs no action since fields with the names
131-
``wife``, ``vice``, and ``office`` do not exist.
132+
This operation does nothing because there are no fields named
133+
``wife``, ``vice``, and ``office``.
132134

133135
- When renaming multiple fields and **some** but not all old field
134136
names refer to non-existing fields, the :operator:`$rename`
@@ -150,7 +152,8 @@ $rename
150152
db.students.update( { _id: 1 }, { $rename: { 'wife': 'alias',
151153
'mobile': 'cell' } } )
152154

153-
The operation renames the ``mobile`` field to ``cell``. No other
155+
This operation renames the ``mobile`` field to ``cell``, and has
156+
no other impact
154157
action occurs.
155158

156159
.. code-block:: javascript
@@ -165,20 +168,21 @@ $rename
165168

166169
.. note::
167170

168-
Before version 2.2, when renaming multiple fields and some but
169-
not all old field names refer to non-existing fields:
171+
Before version 2.2, when renaming multiple fields and only some (but
172+
not all) old field names refer to non-existing fields:
170173

171174
- **if** no field exists with the new field name, the
172175
:operator:`$rename` operator does nothing.
173176

174177
- **if** fields already exist with the new field names, the
175178
:operator:`$rename` operator drops these fields.
176179

177-
Consider the following query that renames both an existing
178-
field ``mobile`` and a non-existing field ``wife``. The
179-
non-existing field ``wife`` is to be set to ``alias``, a name
180-
that already exists.
181-
180+
Consider the following operation that renames both the
181+
field ``mobile``, which exists, the field ``wife``, which
182+
does not exist. The operation will set the
183+
field named ``wife`` ``alias``, which is the name of an
184+
existing field:
185+
182186
.. code-block:: javascript
183187

184188
db.students.update( { _id: 1 }, { $rename: { 'wife': 'alias', 'mobile': 'cell' } } )
@@ -194,5 +198,3 @@ $rename
194198
"name" : { "lname" : "washington" },
195199
"places" : { "d" : "Mt Vernon", "b" : "Colonial Beach" }
196200
}
197-
198-
.. versionadded:: 1.7.2

0 commit comments

Comments
 (0)