Skip to content

Commit 449d039

Browse files
authored
DRIVERS-3058 Include nsType field in ChangeStreamDocument (#1748)
1 parent d05c33e commit 449d039

File tree

3 files changed

+243
-0
lines changed

3 files changed

+243
-0
lines changed

source/change-streams/change-streams.md

+12
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ class ChangeStreamDocument {
120120
*/
121121
ns: Document;
122122

123+
/**
124+
* Only present for ops of type 'create'.
125+
* Only present when the `showExpandedEvents` change stream option is enabled.
126+
*
127+
* The type of the newly created object.
128+
*
129+
* @since 8.1.0
130+
*/
131+
nsType: "collection" | "timeseries" | "view" | null;
132+
123133
/**
124134
* Only present for ops of type 'rename'.
125135
*
@@ -1006,6 +1016,8 @@ There should be no backwards compatibility concerns.
10061016

10071017
## Changelog
10081018

1019+
- 2025-01-29: Add `nsType` to `ChangeStreamDocument`.
1020+
10091021
- 2024-02-09: Migrated from reStructuredText to Markdown.
10101022

10111023
- 2023-08-11: Update server versions for `$changeStreamSplitLargeEvent` test.

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

+145
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
description: "change-streams-nsType"
2+
schemaVersion: "1.7"
3+
runOnRequirements:
4+
- minServerVersion: "8.1.0"
5+
topologies: [ replicaset, sharded ]
6+
serverless: forbid
7+
createEntities:
8+
- client:
9+
id: &client0 client0
10+
useMultipleMongoses: false
11+
- database:
12+
id: &database0 database0
13+
client: *client0
14+
databaseName: *database0
15+
16+
tests:
17+
- description: "nsType is present when creating collections"
18+
operations:
19+
- name: dropCollection
20+
object: *database0
21+
arguments:
22+
collection: &collection0 foo
23+
- name: createChangeStream
24+
object: *database0
25+
arguments:
26+
pipeline: []
27+
showExpandedEvents: true
28+
saveResultAsEntity: &changeStream0 changeStream0
29+
- name: createCollection
30+
object: *database0
31+
arguments:
32+
collection: *collection0
33+
- name: iterateUntilDocumentOrError
34+
object: *changeStream0
35+
expectResult:
36+
operationType: create
37+
nsType: collection
38+
39+
- description: "nsType is present when creating timeseries"
40+
operations:
41+
- name: dropCollection
42+
object: *database0
43+
arguments:
44+
collection: &collection0 foo
45+
- name: createChangeStream
46+
object: *database0
47+
arguments:
48+
pipeline: []
49+
showExpandedEvents: true
50+
saveResultAsEntity: &changeStream0 changeStream0
51+
- name: createCollection
52+
object: *database0
53+
arguments:
54+
collection: *collection0
55+
timeseries:
56+
timeField: "time"
57+
metaField: "meta"
58+
granularity: "minutes"
59+
- name: iterateUntilDocumentOrError
60+
object: *changeStream0
61+
expectResult:
62+
operationType: create
63+
nsType: timeseries
64+
65+
- description: "nsType is present when creating views"
66+
operations:
67+
- name: dropCollection
68+
object: *database0
69+
arguments:
70+
collection: &collection0 foo
71+
- name: createChangeStream
72+
object: *database0
73+
arguments:
74+
pipeline: []
75+
showExpandedEvents: true
76+
saveResultAsEntity: &changeStream0 changeStream0
77+
- name: createCollection
78+
object: *database0
79+
arguments:
80+
collection: *collection0
81+
viewOn: testName
82+
- name: iterateUntilDocumentOrError
83+
object: *changeStream0
84+
expectResult:
85+
operationType: create
86+
nsType: view

0 commit comments

Comments
 (0)