ChangeStreamFlow

class ChangeStreamFlow<T : Any>(wrapped: ChangeStreamPublisher<T>) : Flow<ChangeStreamDocument<T>>

Flow implementation for change streams.

Note: the ChangeStreamDocument class will not be applicable for all change stream outputs. If using custom pipelines that radically change the result, then the withDocumentClass method can be used to provide an alternative document format.

Parameters

T

The type of the result.

Constructors

Link copied to clipboard
constructor(wrapped: ChangeStreamPublisher<T>)

Functions

Link copied to clipboard
fun batchSize(batchSize: Int): ChangeStreamFlow<T>

Sets the number of documents to return per batch.

Link copied to clipboard
fun collation(collation: Collation?): ChangeStreamFlow<T>

Sets the collation options

Link copied to clipboard
open suspend override fun collect(collector: FlowCollector<ChangeStreamDocument<T>>)
Link copied to clipboard
fun comment(comment: String?): ChangeStreamFlow<T>
fun comment(comment: BsonValue?): ChangeStreamFlow<T>

Sets the comment for this operation. A null value means no comment is set.

Link copied to clipboard
fun fullDocument(fullDocument: FullDocument): ChangeStreamFlow<T>

Sets the fullDocument value.

Link copied to clipboard
fun fullDocumentBeforeChange(fullDocumentBeforeChange: FullDocumentBeforeChange): ChangeStreamFlow<T>

Sets the fullDocumentBeforeChange value.

Link copied to clipboard
fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ChangeStreamFlow<T>

Sets the maximum await execution time on the server for this operation.

Link copied to clipboard
fun resumeAfter(resumeToken: BsonDocument): ChangeStreamFlow<T>

Sets the logical starting point for the new change stream.

Link copied to clipboard
fun showExpandedEvents(showExpandedEvents: Boolean): ChangeStreamFlow<T>

Sets whether to include expanded change stream events, which are: createIndexes, dropIndexes, modify, create, shardCollection, reshardCollection, refineCollectionShardKey. False by default.

Link copied to clipboard
fun startAfter(startAfter: BsonDocument): ChangeStreamFlow<T>

Similar to resumeAfter, this option takes a resume token and starts a new change stream returning the first notification after the token.

Link copied to clipboard
fun startAtOperationTime(startAtOperationTime: BsonTimestamp): ChangeStreamFlow<T>

The change stream will only provide changes that occurred at or after the specified timestamp.

Link copied to clipboard
inline fun <R : Any> withDocumentClass(): Flow<R>
fun <R : Any> withDocumentClass(resultClass: Class<R>): Flow<R>

Returns a MongoIterable containing the results of the change stream based on the document class provided.