Docs: Added pipeline example to change stream examples
@@ -22,11 +22,13 @@ import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Aggregates;
import com.mongodb.client.model.changestream.ChangeStreamDocument;
import com.mongodb.client.model.changestream.FullDocument;
import org.bson.BsonDocument;
import org.bson.BsonType;
import org.bson.Document;
+import org.bson.conversions.Bson;
import org.junit.After;
import org.junit.Test;
@@ -656,6 +658,15 @@ public final class DocumentationSamples extends DatabaseTestCase {
cursor.close();
+ // Start Changestream Example 4
+ List<Bson> pipeline = singletonList(Aggregates.match(
+ or(Document.parse("{'fullDocument.username': 'alice'}"), in("operationType", singletonList("delete")))));
+ cursor = inventory.watch(pipeline).iterator();
+ next = cursor.next();
+ // End Changestream Example 4
+
+ cursor.close();
+
stop.set(true);
}
