0

チェンジストリームで監視されるmongodbにコレクションがあります。

protected fun <DocTypeT : Any> startWatcher(collectionName: String, docTypeClass: KClass<DocTypeT>, operationTypes: List<MongoOperationType>, onCollectionChangeFunction: (DocTypeT) -> Unit) {
        val changeStreamPublisher = dbClient.getCollection(collectionName, docTypeClass.java)
            .watch(listOf(Aggregates.match(Filters.`in`("operationType", operationTypes.map { operationType -> operationType.value }.toList()))))
            .fullDocument(FullDocument.UPDATE_LOOKUP)

        changeStreamPublisher.withDocumentClass(docTypeClass.java).toFlux()
            .subscribe(onCollectionChangeFunction)
    }

私が監視しているイベントは、「挿入、更新、置換」です。

イベントは関数で受信されますが、エンティティにはすべて null フィールド (またはプリミティブの既定値) が含まれます。

変更ストリームから作成または更新したオブジェクトを取得する方法はありますか?

4

1 に答える 1