1
1
.. index:: changeStreams notification
2
+ .. _change-events:
2
3
3
4
=============
4
5
Change Events
@@ -37,7 +38,11 @@ stream response document can have.
37
38
"documentKey" : { "_id" : <value> },
38
39
"updateDescription" : {
39
40
"updatedFields" : { <document> },
40
- "removedFields" : [ "<field>", ... ]
41
+ "removedFields" : [ "<field>", ... ],
42
+ "truncatedArrays" : [
43
+ { "field" : <field>, "newSize" : <integer> },
44
+ ...
45
+ ]
41
46
}
42
47
"clusterTime" : <Timestamp>,
43
48
"txnNumber" : <NumberLong>,
@@ -170,6 +175,29 @@ following table describes each field in the change stream response document:
170
175
- array
171
176
- An array of fields that were removed by the update operation.
172
177
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.
173
201
* - ``clusterTime``
174
202
175
203
- Timestamp
@@ -268,10 +296,14 @@ The following example illustrates an ``update`` event:
268
296
updatedFields: {
269
297
270
298
},
271
- removedFields: ['phoneNumber']
299
+ removedFields: ['phoneNumber'],
300
+ truncatedArrays: [ {
301
+ "field" : "vacation_time",
302
+ "newSize" : 36
303
+ } ]
272
304
}
273
305
}
274
-
306
+
275
307
The following example illustrates an ``update`` event for change streams
276
308
opened with the ``fullDocument : updateLookup`` option:
277
309
@@ -292,7 +324,11 @@ opened with the ``fullDocument : updateLookup`` option:
292
324
updatedFields: {
293
325
294
326
},
295
- removedFields: ['phoneNumber']
327
+ removedFields: ['phoneNumber'],
328
+ truncatedArrays: [ {
329
+ "field" : "vacation_time",
330
+ "newSize" : 36
331
+ } ]
296
332
},
297
333
fullDocument: {
298
334
_id: ObjectId("58a4eb4a30c75625e00d2820"),
0 commit comments