Skip to content

Commit 2a27787

Browse files
npentreljeff-allen-mongo
authored andcommitted
DOCSP-13958 add array trunc change stream field
1 parent 336acda commit 2a27787

File tree

2 files changed

+50
-5
lines changed

2 files changed

+50
-5
lines changed

source/reference/change-events.txt

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. index:: changeStreams notification
2+
.. _change-events:
23

34
=============
45
Change Events
@@ -37,7 +38,11 @@ stream response document can have.
3738
"documentKey" : { "_id" : <value> },
3839
"updateDescription" : {
3940
"updatedFields" : { <document> },
40-
"removedFields" : [ "<field>", ... ]
41+
"removedFields" : [ "<field>", ... ],
42+
"truncatedArrays" : [
43+
{ "field" : <field>, "newSize" : <integer> },
44+
...
45+
]
4146
}
4247
"clusterTime" : <Timestamp>,
4348
"txnNumber" : <NumberLong>,
@@ -170,6 +175,29 @@ following table describes each field in the change stream response document:
170175
- array
171176
- An array of fields that were removed by the update operation.
172177

178+
* - ``updateDescription.truncatedArrays``
179+
- array
180+
- An array of documents which record array truncations performed
181+
with pipeline-based updates using one or more of the following
182+
stages:
183+
184+
- :pipeline:`$addFields`
185+
- :pipeline:`$set`
186+
- :pipeline:`$replaceRoot`
187+
- :pipeline:`$replaceWith`
188+
189+
.. note::
190+
191+
If the entire array is replaced, the truncations will be
192+
reported under ``updateDescription.updatedFields``.
193+
194+
* - ``updateDescription.truncatedArrays.field``
195+
- string
196+
- The name of the truncated field.
197+
198+
* - ``updateDescription.truncatedArrays.newSize``
199+
- integer
200+
- The number of elements in the truncated array.
173201
* - ``clusterTime``
174202

175203
- Timestamp
@@ -268,10 +296,14 @@ The following example illustrates an ``update`` event:
268296
updatedFields: {
269297
270298
},
271-
removedFields: ['phoneNumber']
299+
removedFields: ['phoneNumber'],
300+
truncatedArrays: [ {
301+
"field" : "vacation_time",
302+
"newSize" : 36
303+
} ]
272304
}
273305
}
274-
306+
275307
The following example illustrates an ``update`` event for change streams
276308
opened with the ``fullDocument : updateLookup`` option:
277309

@@ -292,7 +324,11 @@ opened with the ``fullDocument : updateLookup`` option:
292324
updatedFields: {
293325
294326
},
295-
removedFields: ['phoneNumber']
327+
removedFields: ['phoneNumber'],
328+
truncatedArrays: [ {
329+
"field" : "vacation_time",
330+
"newSize" : 36
331+
} ]
296332
},
297333
fullDocument: {
298334
_id: ObjectId("58a4eb4a30c75625e00d2820"),

source/release-notes/5.0.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ Projection
7676
Transactions
7777
------------
7878

79+
.. _5.0-rel-notes-change-streams:
80+
81+
Change Streams
82+
--------------
83+
84+
Starting in MongoDB 5.0, :ref:`change-events`
85+
contain the field ``updateDescription.truncatedArrays`` to record array
86+
truncations.
87+
7988
.. _5.0-rel-notes-security:
8089

8190
Security Improvements
@@ -153,7 +162,7 @@ Starting in MongoDB 5.0, the :dbcommand:`reIndex` command and the
153162
Schema Validation Failures Explained
154163
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155164

156-
MongoDB 5.0 adds detailed explanations when a document fails
165+
MongoDB 5.0 adds detailed explanations when a document fails
157166
:ref:`schema validation <schema-validation-overview>`.
158167

159168
Repair Option in ``validate`` Command

0 commit comments

Comments
 (0)