Skip to content

Commit

Permalink
Merge pull request #34083 from ruget/ChangeStreamOptionsWithfullDocum…
Browse files Browse the repository at this point in the history
…entBeforeChange

Add fullDocumentBeforeChange to ChangeStreamOptions
  • Loading branch information
loicmathieu authored Jul 4, 2023
2 parents 1b6013f + af4353e commit f694d96
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.mongodb.client.model.Collation;
import com.mongodb.client.model.changestream.FullDocument;
import com.mongodb.client.model.changestream.FullDocumentBeforeChange;
import com.mongodb.reactivestreams.client.ChangeStreamPublisher;

/**
Expand All @@ -15,6 +16,7 @@
public class ChangeStreamOptions {

private FullDocument fullDocument;
private FullDocumentBeforeChange fullDocumentBeforeChange;
private BsonDocument resumeToken;
private BsonDocument startAfterResumeToken;
private BsonTimestamp startAtOperationTime;
Expand All @@ -33,6 +35,17 @@ public ChangeStreamOptions fullDocument(FullDocument fullDocument) {
return this;
}

/**
* Sets the fullDocumentBeforeChange value.
*
* @param fullDocumentBeforeChange the fullDocumentBeforeChange
* @return this
*/
public ChangeStreamOptions fullDocumentBeforeChange(FullDocumentBeforeChange fullDocumentBeforeChange) {
this.fullDocumentBeforeChange = fullDocumentBeforeChange;
return this;
}

/**
* Sets the logical starting point for the new change stream.
*
Expand Down Expand Up @@ -114,6 +127,9 @@ public <T> ChangeStreamPublisher<T> apply(ChangeStreamPublisher<T> stream) {
if (fullDocument != null) {
publisher = publisher.fullDocument(fullDocument);
}
if (fullDocumentBeforeChange != null) {
publisher = publisher.fullDocumentBeforeChange(fullDocumentBeforeChange);
}
if (resumeToken != null) {
publisher = publisher.resumeAfter(resumeToken);
}
Expand Down

0 comments on commit f694d96

Please sign in to comment.