Skip to content

Commit a5b7061

Browse files
author
Dave
authored
DOCSP-20004 updates for update pt3 v5.1 (#112)
* DOCSP-20004 updates for update pt3 * Clarify bit layout * Better find commands * Review comments
1 parent 77754fc commit a5b7061

File tree

9 files changed

+84
-90
lines changed

9 files changed

+84
-90
lines changed

source/includes/fact-bulkwrite-explainable.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

source/reference/method/Date.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ collection, the following operation inserts a document with the field
6161

6262
.. code-block:: javascript
6363

64-
db.products.update(
64+
db.products.updateOne(
6565
{ _id: 1 },
6666
{
6767
$set: { item: "apple" },

source/reference/method/WriteResult.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ Definition
2424
- :method:`db.collection.update()`
2525
- :method:`db.collection.remove()`
2626

27+
.. note::
28+
29+
:method:`db.collection.insert()` and
30+
:method:`db.collection.update()` are deprecated.
31+
32+
The results returned by the replacement methods have a different
33+
format. For output similar to :method:`WriteResult`, consider
34+
using :method:`db.collection.bulkWrite()`.
35+
2736
Properties
2837
----------
2938

@@ -106,3 +115,4 @@ The :method:`WriteResult` has the following properties:
106115

107116
- :method:`WriteResult.hasWriteError()`
108117
- :method:`WriteResult.hasWriteConcernError()`
118+

source/reference/method/db.collection.insertMany.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,8 @@ unique within the collection to avoid duplicate key error.
131131
Explainability
132132
~~~~~~~~~~~~~~
133133

134-
135-
.. Broke out to be used in the new CRUD API docs
136-
137-
.. |write-method| replace:: :method:`~db.collection.insertMany()`
138-
.. |old-write-method| replace:: :method:`~db.collection.insert()`
139-
140-
.. include:: /includes/fact-bulkwrite-explainable.rst
141-
134+
:method:`~db.collection.insertMany()` is not compatible with
135+
:method:`db.collection.explain()`.
142136

143137
Error Handling
144138
~~~~~~~~~~~~~~

source/reference/method/db.collection.insertOne.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,8 @@ unique within the collection to avoid duplicate key error.
102102
Explainability
103103
~~~~~~~~~~~~~~
104104

105-
.. |write-method| replace:: :method:`~db.collection.insertOne()`
106-
.. |old-write-method| replace:: :method:`~db.collection.insert()`
107-
108-
109-
.. include:: /includes/fact-bulkwrite-explainable.rst
105+
:method:`~db.collection.insertOne()` is not compatible with
106+
:method:`db.collection.explain()`.
110107

111108
Error Handling
112109
~~~~~~~~~~~~~~

source/reference/method/db.collection.updateMany.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,8 @@ full shard key in the ``filter``.
307307
Explainability
308308
~~~~~~~~~~~~~~
309309

310-
.. |write-method| replace:: :method:`~db.collection.updateMany()`
311-
.. |old-write-method| replace:: :method:`~db.collection.update()`
312-
313-
.. include:: /includes/fact-bulkwrite-explainable.rst
310+
:method:`~db.collection.updateMany()` is not compatible with
311+
:method:`db.collection.explain()`.
314312

315313
Transactions
316314
~~~~~~~~~~~~

source/reference/method/db.collection.updateOne.txt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ Definition
1717

1818
.. method:: db.collection.updateOne(filter, update, options)
1919

20-
2120
.. include:: /includes/fact-mongosh-shell-method.rst
2221

23-
24-
.. versionadded:: 3.2
25-
2622
Updates a single document within the collection based on the filter.
2723

2824
Syntax
@@ -384,10 +380,8 @@ See also:
384380
Explainability
385381
~~~~~~~~~~~~~~
386382

387-
.. |write-method| replace:: :method:`~db.collection.updateOne()`
388-
.. |old-write-method| replace:: :method:`~db.collection.update()`
389-
390-
.. include:: /includes/fact-bulkwrite-explainable.rst
383+
:method:`~db.collection.updateOne()` is not compatible with
384+
:method:`db.collection.explain()`.
391385

392386
Transactions
393387
~~~~~~~~~~~~

source/reference/operator/aggregation/dateAdd.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,17 @@ to add delivery dates to the documents:
206206

207207
.. code-block:: javascript
208208

209-
db.shipping.update(
209+
db.shipping.updateOne(
210210
{ custId: 456 },
211211
{ $set: { deliveryDate: ISODate( "2021-01-10" ) } }
212212
)
213213

214-
db.shipping.update(
214+
db.shipping.updateOne(
215215
{ custId: 457 },
216216
{ $set: { deliveryDate: ISODate( "2021-03-01" ) } }
217217
)
218218

219-
db.shipping.update(
219+
db.shipping.updateOne(
220220
{ custId: 458 },
221221
{ $set: { deliveryDate: ISODate( "2021-03-02" ) } }
222222
)

source/reference/operator/update/bit.txt

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -47,119 +47,125 @@ Behavior
4747
Examples
4848
--------
4949

50-
Bitwise AND
51-
~~~~~~~~~~~
52-
53-
Consider the following document inserted into the collection
54-
``switches``:
50+
The following examples use the ``switches`` collection:
5551

5652
.. code-block:: javascript
5753

58-
{ _id: 1, expdata: NumberInt(13) }
54+
db.switches.insertMany( [
55+
{ _id: 1, expdata: Int32(13) },
56+
{ _id: 2, expdata: Int32(3) },
57+
{ _id: 3, expdata: Int32(1) }
58+
] )
59+
60+
Bitwise AND
61+
~~~~~~~~~~~
5962

60-
The following :method:`~db.collection.update()` operation updates the
61-
``expdata`` field to the result of a bitwise ``and`` operation between
62-
the current value ``NumberInt(13)`` (i.e. ``1101``) and
63-
``NumberInt(10)`` (i.e. ``1010``):
63+
Use a bitwise ``and`` in the :method:`~db.collection.updateOne()`
64+
operation to update ``expdata``.
6465

6566
.. code-block:: javascript
6667

67-
db.switches.update(
68+
db.switches.updateOne(
6869
{ _id: 1 },
69-
{ $bit: { expdata: { and: NumberInt(10) } } }
70+
{ $bit: { expdata: { and: Int32( 10 ) } } }
7071
)
7172

72-
The bitwise ``and`` operation results in the integer 8 (i.e. ``1000``):
73+
The bitwise ``and`` operation:
7374

74-
.. code-block:: none
75+
- gets the bitwise value of ``expdata``
76+
- uses ``and`` to apply the bitwise value of Int32(10)
77+
- updates ``expdata`` with the result, 1000
7578

76-
1101
77-
1010
79+
.. code-block:: javascript
80+
:copyable: false
81+
82+
1101 // expdata
83+
1010 // Int32(10)
7884
----
7985
1000
8086

81-
And the updated document has the following value for ``expdata``:
87+
Binary 1000 is equivalent to Int32(8). The
88+
``db.switches.find( { _id: 1 } )`` command returns the following
89+
document:
8290

8391
.. code-block:: javascript
8492

8593
{ "_id" : 1, "expdata" : 8 }
8694

87-
:binary:`~bin.mongosh` displays ``NumberInt(8)`` as ``8``.
8895

8996
Bitwise OR
9097
~~~~~~~~~~
9198

92-
Consider the following document inserted into the collection
93-
``switches``:
94-
95-
.. code-block:: javascript
96-
97-
{ _id: 2, expdata: NumberLong(3) }
98-
99-
The following :method:`~db.collection.update()` operation updates the
100-
``expdata`` field to the result of a bitwise ``or`` operation between
101-
the current value ``NumberLong(3)`` (i.e. ``0011``) and
102-
``NumberInt(5)`` (i.e. ``0101``):
99+
Use a bitwise ``or`` in the :method:`~db.collection.updateOne()`
100+
operation to update ``expdata``.
103101

104102
.. code-block:: javascript
105103

106-
db.switches.update(
104+
db.switches.updateOne(
107105
{ _id: 2 },
108-
{ $bit: { expdata: { or: NumberInt(5) } } }
106+
{ $bit: { expdata: { or: Int32( 5 ) } } }
109107
)
110108

111-
The bitwise ``or`` operation results in the integer 7 (i.e. ``0111``):
109+
The bitwise ``or`` operation:
110+
111+
- gets the bitwise value of ``expdata``
112+
- uses ``or`` to apply the bitwise value of Int32(5)
113+
- updates ``expdata`` with the result, 0111
112114

113-
.. code-block:: none
115+
.. code-block:: javascript
116+
:copyable: false
114117

115-
0011
116-
0101
118+
0111 // expdata
119+
0101 // Int32(5)
117120
----
118121
0111
119122

120-
And the updated document has the following value for ``expdata``:
123+
Binary 0111 is equivalent to Int32(7). The
124+
``db.switches.find( { _id: 2 } )`` command returns the following
125+
document:
121126

122127
.. code-block:: javascript
123128

124-
{ "_id" : 2, "expdata" : NumberLong(7) }
129+
{ "_id" : 2, "expdata" : 7 }
130+
125131

126132
Bitwise XOR
127133
~~~~~~~~~~~
128134

129-
Consider the following document in the collection ``switches``:
135+
Use a bitwise ``xor`` in the :method:`~db.collection.updateOne()`
136+
operation to update ``expdata``.
130137

131138
.. code-block:: javascript
132139

133-
{ _id: 3, expdata: NumberLong(1) }
134-
135-
The following :method:`~db.collection.update()` operation updates the
136-
``expdata`` field to the result of a bitwise ``xor`` operation between
137-
the current value ``NumberLong(1)`` (i.e. ``0001``) and
138-
``NumberInt(5)`` (i.e. ``0101``):
139-
140-
.. code-block:: javascript
141-
142-
db.switches.update(
140+
db.switches.updateOne(
143141
{ _id: 3 },
144-
{ $bit: { expdata: { xor: NumberInt(5) } } }
142+
{ $bit: { expdata: { xor: Int32( 5 ) } } }
145143
)
146144

147-
The bitwise ``xor`` operation results in the integer 4:
145+
The bitwise ``and`` operation:
148146

149-
.. code-block:: none
147+
- gets the bitwise value of ``expdata``
148+
- uses ``and`` to apply the bitwise value of Int32(5)
149+
- updates ``expdata`` with the result, 0100
150150

151-
0001
152-
0101
151+
.. code-block:: javascript
152+
:copyable: false
153+
154+
0001 // expdata
155+
0101 // Int32(5)
153156
----
154157
0100
155158

156-
And the updated document has the following value for ``expdata``:
159+
Binary 0100 is equivalent to ``Int32(4)``. The
160+
``db.switches.find( { _id: 3 } )`` command returns the following
161+
document:
157162

158163
.. code-block:: javascript
159164

160-
{ "_id" : 3, "expdata" : NumberLong(4) }
165+
{ "_id" : 1, "expdata" : 4 }
161166

162167
.. seealso::
163168

164-
- :method:`db.collection.update()`
169+
- :method:`db.collection.updateOne()`
165170
- :method:`db.collection.findAndModify()`
171+

0 commit comments

Comments
 (0)