Skip to content

Commit e1a513f

Browse files
authored
DRIVERS-2285 Add wallTime field to change stream events (#1219)
1 parent 10ffccd commit e1a513f

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

source/change-streams/change-streams.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Change Streams
99
:Status: Accepted
1010
:Type: Standards
1111
:Minimum Server Version: 3.6
12-
:Last Modified: 2022-04-13
13-
:Version: 1.14
12+
:Last Modified: 2022-05-17
13+
:Version: 1.15
1414

1515
.. contents::
1616

@@ -203,6 +203,12 @@ If an aggregate command with a ``$changeStream`` stage completes successfully, t
203203
* pre-image is unavailable, this will be explicitly set to null.
204204
*/
205205
fullDocumentBeforeChange: Document | null;
206+
207+
/**
208+
* The wall time from the mongod that the change event originated from.
209+
* Populated for server versions 6.0 and above.
210+
*/
211+
wallTime: Optional<Datetime>;
206212
}
207213
208214
class UpdateDescription {
@@ -999,3 +1005,5 @@ Changelog
9991005
| 2022-04-13 | Support returning point-in-time pre and post-images with |
10001006
| | ``fullDocumentBeforeChange`` and ``fullDocument``. |
10011007
+------------+------------------------------------------------------------+
1008+
| 2022-05-17 | Added ``wallTime`` to ``ChangeStreamDocument``. |
1009+
+------------+------------------------------------------------------------+

source/change-streams/tests/unified/change-streams.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,48 @@
17481748
]
17491749
}
17501750
]
1751+
},
1752+
{
1753+
"description": "Test wallTime field is set in a change event",
1754+
"runOnRequirements": [
1755+
{
1756+
"minServerVersion": "6.0.0"
1757+
}
1758+
],
1759+
"operations": [
1760+
{
1761+
"name": "createChangeStream",
1762+
"object": "collection0",
1763+
"arguments": {
1764+
"pipeline": []
1765+
},
1766+
"saveResultAsEntity": "changeStream0"
1767+
},
1768+
{
1769+
"name": "insertOne",
1770+
"object": "collection0",
1771+
"arguments": {
1772+
"document": {
1773+
"_id": 1,
1774+
"a": 1
1775+
}
1776+
}
1777+
},
1778+
{
1779+
"name": "iterateUntilDocumentOrError",
1780+
"object": "changeStream0",
1781+
"expectResult": {
1782+
"operationType": "insert",
1783+
"ns": {
1784+
"db": "database0",
1785+
"coll": "collection0"
1786+
},
1787+
"wallTime": {
1788+
"$$exists": true
1789+
}
1790+
}
1791+
}
1792+
]
17511793
}
17521794
]
17531795
}

source/change-streams/tests/unified/change-streams.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,3 +904,24 @@ tests:
904904
pipeline: [ { $changeStream: {} } ]
905905
commandName: aggregate
906906
databaseName: *database0
907+
908+
- description: "Test wallTime field is set in a change event"
909+
runOnRequirements:
910+
- minServerVersion: "6.0.0"
911+
operations:
912+
- name: createChangeStream
913+
object: *collection0
914+
arguments: { pipeline: [] }
915+
saveResultAsEntity: &changeStream0 changeStream0
916+
- name: insertOne
917+
object: *collection0
918+
arguments:
919+
document: { "_id": 1, "a": 1 }
920+
- name: iterateUntilDocumentOrError
921+
object: *changeStream0
922+
expectResult:
923+
operationType: "insert"
924+
ns:
925+
db: *database0
926+
coll: *collection0
927+
wallTime: { $$exists: true }

0 commit comments

Comments
 (0)