[DRIVERS-436] Add pipeline stage to ChangeStreams example for Docs Created: 05/Jan/18  Updated: 28/Oct/23  Resolved: 25/Feb/19

Status: Closed
Project: Drivers
Component/s: Docs Examples
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-2463 Add pipeline stage to ChangeStreams e... Closed
depends on CSHARP-2148 Add pipeline stage to ChangeStreams e... Closed
depends on CXX-1494 Add pipeline stage to ChangeStreams e... Closed
depends on GODRIVER-194 Add pipeline stage to ChangeStreams e... Closed
depends on JAVA-2732 Add pipeline stage to ChangeStreams e... Closed
depends on MOTOR-186 Add pipeline stage to ChangeStreams e... Closed
depends on NODE-1288 Add pipeline stage to ChangeStreams e... Closed
depends on PHPLIB-310 Add pipeline stage to ChangeStreams e... Closed
depends on PYTHON-1448 Add pipeline stage to ChangeStreams e... Closed
depends on RUBY-1275 Add pipeline stage to ChangeStreams e... Closed
Related
related to DRIVERS-682 Update change stream docs example for... Closed
is related to DRIVERS-414 ChangeStreams Examples for Docs Closed
is related to DRIVERS-434 Provide code samples for MongoDB 3.6 ... Closed
is related to DRIVERS-537 Modify Change Stream Output Examples Closed
Driver Compliance:
Key Status/Resolution FixVersion
NODE-1288 Fixed 3.0.2
SCALA-368 Fixed
PYTHON-1448 Fixed 3.6.1
CSHARP-2148 Duplicate
PERL-845 Won't Fix
RUBY-1275 Fixed 2.5.1
JAVA-2732 Fixed
CXX-1494 Fixed 3.4.0
PHPLIB-310 Fixed 1.3.0
MOTOR-186 Fixed 1.2.1
GODRIVER-194 Fixed 1.0.0-rc1
CDRIVER-2463 Fixed 1.10.0

 Description   

In a previous ticket DRIVERS-414, included Example 1-3. This ticket is to add the Example 4 sections to the existing example :

// Start Changestream Example 1
 
MongoCursor<Document> cursor = inventory.watch().iterator();
Document next = cursor.next();
 
// End Changestream Example 1

// Start Changestream Example 2
 
MongoCursor<Document> cursor = 
inventory.watch().fullDocument(FullDocument.UPDATE_LOOKUP).iterator();
Document next = cursor.next();
 
// End Changestream Example 2

// Start Changestream Example 3
 
Document resumeToken = next.get("_id", Document.class);
MongoCursor<Document> cursor = inventory.watch().resumeAfter(resumeToken).iterator();
cursor.next();
 
// End Changestream Example 3

// Start Changestream Example 4
 
List<Bson> pipeline = singletonList(Aggregates.match(Filters.or(
   Document.parse("{'fullDocument.username': 'alice'}"),
   Filters.in("operationType", asList("delete")))));
 
// End Changestream Example 4



 Comments   
Comment by Kevin Albertson [ 13/Aug/18 ]

Should the 4th example create a change stream cursor and iterate once, like the other examples? Right now it just creates the aggregation pipeline.

Comment by A. Jesse Jiryu Davis [ 14/Jan/18 ]

jeff.yemin, the 4th example is super-Javaey. If this were a normal language would it be like?:

pipeline = {"$match": {"$or": [{"fullDocument.username": "alice"}, {"operationType": {"$in": ["delete"]}}]}}

If so, why do we use $in for a one-element list instead of just?:

pipeline = {"$match": {"$or": [{"fullDocument.username": "alice"}, {"operationType": "delete"}]}}

Generated at Thu Feb 08 08:21:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.