Skip to content

Commit 2eb0b1f

Browse files
authored
update changestream example
1 parent c16f785 commit 2eb0b1f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

source/examples/ServerManualCodeExamples.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,23 @@ fun main() = runBlocking {
646646
// End Changestream Example 3
647647

648648
// Start Changestream Example 4
649+
val pipeline = listOf(
650+
Aggregates.match(
651+
or(
652+
eq("fullDocument.username", "alice"),
653+
`in`("operationType", listOf("delete"))
654+
)
655+
))
656+
657+
val job = launch {
658+
val changeStream = collection.watch(pipeline)
659+
changeStream.collect {
660+
println("Received a change event: $it")
661+
}
662+
}
663+
// End Changestream Example 4
664+
665+
// Start Changestream Example 4 Alt
649666
val pipeline = listOf(
650667
Aggregates.match(Filters.`in`("operationType",
651668
listOf("insert", "update")))
@@ -657,7 +674,7 @@ fun main() = runBlocking {
657674
println("Received a change event: $it")
658675
}
659676
}
660-
// End Changestream Example 4
677+
// End Changestream Example 4 Alt
661678

662679
// Start Stable API Example 1
663680
val serverApi = ServerApi.builder()

0 commit comments

Comments
 (0)