Skip to content

Commit 463b753

Browse files
authored
Add showExpandedEvents to change stream pipeline stage (#977)
JAVA-4585
1 parent c70c2d2 commit 463b753

File tree

11 files changed

+643
-6
lines changed

11 files changed

+643
-6
lines changed

driver-core/src/main/com/mongodb/internal/operation/ChangeStreamOperation.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class ChangeStreamOperation<T> implements AsyncReadOperation<AsyncBatchCu
6767
private BsonDocument resumeAfter;
6868
private BsonDocument startAfter;
6969
private BsonTimestamp startAtOperationTime;
70+
private boolean showExpandedEvents;
7071

7172
/**
7273
* Construct a new instance.
@@ -342,6 +343,33 @@ public ChangeStreamOperation<T> comment(final BsonValue comment) {
342343
return this;
343344
}
344345

346+
/**
347+
* Gets whether to include expanded change stream events. Default false.
348+
*
349+
* @return true if expanded change stream events should be included.
350+
* @since 4.7
351+
* @mongodb.server.release 6.0
352+
*/
353+
public boolean getShowExpandedEvents() {
354+
return this.showExpandedEvents;
355+
}
356+
357+
/**
358+
* Sets whether to include expanded change stream events, which are:
359+
* createIndexes, dropIndexes, modify, create, shardCollection,
360+
* reshardCollection, refineCollectionShardKey. False by default.
361+
*
362+
* @param showExpandedEvents true to include expanded events
363+
* @return this
364+
* @since 4.7
365+
* @mongodb.server.release 6.0
366+
*/
367+
public ChangeStreamOperation<T> showExpandedEvents(final boolean showExpandedEvents) {
368+
this.showExpandedEvents = showExpandedEvents;
369+
return this;
370+
}
371+
372+
345373
@Override
346374
public BatchCursor<T> execute(final ReadBinding binding) {
347375
return withReadConnectionSource(binding, new CallableWithSource<BatchCursor<T>>() {
@@ -444,6 +472,10 @@ public BsonArray create() {
444472
changeStream.append("allChangesForCluster", BsonBoolean.TRUE);
445473
}
446474

475+
if (showExpandedEvents) {
476+
changeStream.append("showExpandedEvents", BsonBoolean.TRUE);
477+
}
478+
447479
if (resumeAfter != null) {
448480
changeStream.append("resumeAfter", resumeAfter);
449481
}

0 commit comments

Comments
 (0)