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
5 changes: 4 additions & 1 deletion src/change_stream/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{cursor::CursorSpecification, options::ChangeStreamOptions};

#[cfg(test)]
use bson::Bson;
use bson::{Document, RawBson, RawDocumentBuf, Timestamp};
use bson::{DateTime, Document, RawBson, RawDocumentBuf, Timestamp};
use serde::{Deserialize, Serialize};

/// An opaque token used for resuming an interrupted
Expand Down Expand Up @@ -87,6 +87,9 @@ pub struct ChangeStreamEvent<T> {
/// The cluster time at which the change occurred.
pub cluster_time: Option<Timestamp>,

/// The wall time from the mongod that the change event originated from.
pub wall_time: Option<DateTime>,

/// The `Document` created or modified by the `insert`, `replace`, `delete`, `update`
/// operations (i.e. CRUD operations).
///
Expand Down
42 changes: 42 additions & 0 deletions src/test/spec/json/change-streams/unified/change-streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,48 @@
]
}
]
},
{
"description": "Test wallTime field is set in a change event",
"runOnRequirements": [
{
"minServerVersion": "6.0.0"
}
],
"operations": [
{
"name": "createChangeStream",
"object": "collection0",
"arguments": {
"pipeline": []
},
"saveResultAsEntity": "changeStream0"
},
{
"name": "insertOne",
"object": "collection0",
"arguments": {
"document": {
"_id": 1,
"a": 1
}
}
},
{
"name": "iterateUntilDocumentOrError",
"object": "changeStream0",
"expectResult": {
"operationType": "insert",
"ns": {
"db": "database0",
"coll": "collection0"
},
"wallTime": {
"$$exists": true
}
}
}
]
}
]
}
21 changes: 21 additions & 0 deletions src/test/spec/json/change-streams/unified/change-streams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -737,3 +737,24 @@ tests:
pipeline: [ { $changeStream: {} } ]
commandName: aggregate
databaseName: *database0

- description: "Test wallTime field is set in a change event"
runOnRequirements:
- minServerVersion: "6.0.0"
operations:
- name: createChangeStream
object: *collection0
arguments: { pipeline: [] }
saveResultAsEntity: &changeStream0 changeStream0
- name: insertOne
object: *collection0
arguments:
document: { "_id": 1, "a": 1 }
- name: iterateUntilDocumentOrError
object: *changeStream0
expectResult:
operationType: "insert"
ns:
db: *database0
coll: *collection0
wallTime: { $$exists: true }