Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/change_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,13 @@ export interface ChangeStreamCreateDocument
ChangeStreamDocumentCollectionUUID {
/** Describes the type of operation represented in this change notification */
operationType: 'create';

/**
* The type of the newly created object.
*
* @sinceServerVersion 8.1.0
*/
nsType?: 'collection' | 'timeseries' | 'view';
}

/**
Expand Down
145 changes: 145 additions & 0 deletions test/spec/change-streams/unified/change-streams-nsType.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"description": "change-streams-nsType",
"schemaVersion": "1.7",
"runOnRequirements": [
{
"minServerVersion": "8.1.0",
"topologies": [
"replicaset",
"sharded"
],
"serverless": "forbid"
}
],
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": false
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "database0"
}
}
],
"tests": [
{
"description": "nsType is present when creating collections",
"operations": [
{
"name": "dropCollection",
"object": "database0",
"arguments": {
"collection": "foo"
}
},
{
"name": "createChangeStream",
"object": "database0",
"arguments": {
"pipeline": [],
"showExpandedEvents": true
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "createCollection",
"object": "database0",
"arguments": {
"collection": "foo"
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "create",
"nsType": "collection"
}
}
]
},
{
"description": "nsType is present when creating timeseries",
"operations": [
{
"name": "dropCollection",
"object": "database0",
"arguments": {
"collection": "foo"
}
},
{
"name": "createChangeStream",
"object": "database0",
"arguments": {
"pipeline": [],
"showExpandedEvents": true
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "createCollection",
"object": "database0",
"arguments": {
"collection": "foo",
"timeseries": {
"timeField": "time",
"metaField": "meta",
"granularity": "minutes"
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "create",
"nsType": "timeseries"
}
}
]
},
{
"description": "nsType is present when creating views",
"operations": [
{
"name": "dropCollection",
"object": "database0",
"arguments": {
"collection": "foo"
}
},
{
"name": "createChangeStream",
"object": "database0",
"arguments": {
"pipeline": [],
"showExpandedEvents": true
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "createCollection",
"object": "database0",
"arguments": {
"collection": "foo",
"viewOn": "testName"
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "create",
"nsType": "view"
}
}
]
}
]
}
86 changes: 86 additions & 0 deletions test/spec/change-streams/unified/change-streams-nsType.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
description: "change-streams-nsType"
schemaVersion: "1.7"
runOnRequirements:
- minServerVersion: "8.1.0"
topologies: [ replicaset, sharded ]
serverless: forbid
createEntities:
- client:
id: &client0 client0
useMultipleMongoses: false
- database:
id: &database0 database0
client: *client0
databaseName: *database0

tests:
- description: "nsType is present when creating collections"
operations:
- name: dropCollection
object: *database0
arguments:
collection: &collection0 foo
- name: createChangeStream
object: *database0
arguments:
pipeline: []
showExpandedEvents: true
saveResultAsEntity: &changeStream0 changeStream0
- name: createCollection
object: *database0
arguments:
collection: *collection0
- name: iterateUntilDocumentOrError
object: *changeStream0
expectResult:
operationType: create
nsType: collection

- description: "nsType is present when creating timeseries"
operations:
- name: dropCollection
object: *database0
arguments:
collection: &collection0 foo
- name: createChangeStream
object: *database0
arguments:
pipeline: []
showExpandedEvents: true
saveResultAsEntity: &changeStream0 changeStream0
- name: createCollection
object: *database0
arguments:
collection: *collection0
timeseries:
timeField: "time"
metaField: "meta"
granularity: "minutes"
- name: iterateUntilDocumentOrError
object: *changeStream0
expectResult:
operationType: create
nsType: timeseries

- description: "nsType is present when creating views"
operations:
- name: dropCollection
object: *database0
arguments:
collection: &collection0 foo
- name: createChangeStream
object: *database0
arguments:
pipeline: []
showExpandedEvents: true
saveResultAsEntity: &changeStream0 changeStream0
- name: createCollection
object: *database0
arguments:
collection: *collection0
viewOn: testName
- name: iterateUntilDocumentOrError
object: *changeStream0
expectResult:
operationType: create
nsType: view