Interface RemoteMongoCollection<DocumentT>
-
- Type Parameters:
DocumentT
- The type that this collection will encode documents from and decode documents to.
- All Known Implementing Classes:
RemoteMongoCollectionImpl
public interface RemoteMongoCollection<DocumentT>
The RemoteMongoCollection interface provides read and write access to documents.Use
RemoteMongoDatabase.getCollection(java.lang.String)
to get a collection instance.Before any access is possible, there must be an active, logged-in user. See
StitchAuth
for how to log in.Create, read, update and delete (CRUD) functionality is available depending on the privileges of the active logged-in user. You can set up Roles in the Stitch console. Stitch checks any given request against the Roles for the active user and determines whether the request is permitted for each requested document.
-
-
Example
// Note: log in first -- see StitchAuth // Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Find 20 documents movieDetails.find() .projection(new Document().append("title", 1).append("year", 1)) .limit(20) .forEach(document -> { // Print documents to the log. Log.i(TAG, "Got document: " + document.toString()); });
-
-
-
Method Summary
Modifier and Type Method Description RemoteAggregateIterable<DocumentT>
aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.<ResultT> RemoteAggregateIterable<ResultT>
aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents according to the specified aggregation pipeline.Task<Long>
count()
Counts the number of documents in the collection.Task<Long>
count(Bson filter)
Counts the number of documents in the collection according to the given options.Task<Long>
count(Bson filter, RemoteCountOptions options)
Counts the number of documents in the collection according to the given options.Task<RemoteDeleteResult>
deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter.Task<RemoteDeleteResult>
deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter.RemoteFindIterable<DocumentT>
find()
Finds all documents in the collection.<ResultT> RemoteFindIterable<ResultT>
find(Class<ResultT> resultClass)
Finds all documents in the collection.RemoteFindIterable<DocumentT>
find(Bson filter)
Finds all documents in the collection that match the given filter.<ResultT> RemoteFindIterable<ResultT>
find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection that match the given filter.Task<DocumentT>
findOne()
Finds a document in the collection.<ResultT> Task<ResultT>
findOne(Class<ResultT> resultClass)
Finds a document in the collection.Task<DocumentT>
findOne(Bson filter)
Finds a document in the collection.Task<DocumentT>
findOne(Bson filter, RemoteFindOptions options)
Finds a document in the collection.<ResultT> Task<ResultT>
findOne(Bson filter, RemoteFindOptions options, Class<ResultT> resultClass)
Finds a document in the collection.<ResultT> Task<ResultT>
findOne(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection.Task<DocumentT>
findOneAndDelete(Bson filter)
Finds a document in the collection and delete it.Task<DocumentT>
findOneAndDelete(Bson filter, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and delete it.<ResultT> Task<ResultT>
findOneAndDelete(Bson filter, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and delete it.<ResultT> Task<ResultT>
findOneAndDelete(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection and delete it.Task<DocumentT>
findOneAndReplace(Bson filter, Bson replacement)
Finds a document in the collection and replaces it with the given document.Task<DocumentT>
findOneAndReplace(Bson filter, Bson replacement, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and replaces it with the given document.<ResultT> Task<ResultT>
findOneAndReplace(Bson filter, Bson replacement, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.<ResultT> Task<ResultT>
findOneAndReplace(Bson filter, Bson replacement, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.Task<DocumentT>
findOneAndUpdate(Bson filter, Bson update)
Finds a document in the collection and performs the given update.Task<DocumentT>
findOneAndUpdate(Bson filter, Bson update, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and performs the given update.<ResultT> Task<ResultT>
findOneAndUpdate(Bson filter, Bson update, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.<ResultT> Task<ResultT>
findOneAndUpdate(Bson filter, Bson update, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.CodecRegistry
getCodecRegistry()
Get the codec registry for the RemoteMongoCollection.Class<DocumentT>
getDocumentClass()
Get the class of documents stored in this collection.MongoNamespace
getNamespace()
Gets the namespace of this collection, i.e.Task<RemoteInsertManyResult>
insertMany(List<? extends DocumentT> documents)
Inserts one or more documents.Task<RemoteInsertOneResult>
insertOne(DocumentT document)
Inserts the provided document.Sync<DocumentT>
sync()
A set of synchronization related operations on this collection.Task<RemoteUpdateResult>
updateMany(Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.Task<RemoteUpdateResult>
updateMany(Bson filter, Bson update, RemoteUpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.Task<RemoteUpdateResult>
updateOne(Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.Task<RemoteUpdateResult>
updateOne(Bson filter, Bson update, RemoteUpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>>
watch()
Watches a collection.Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>>
watch(BsonValue... ids)
Watches specified IDs in a collection.Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>>
watch(ObjectId... ids)
Watches specified IDs in a collection.Task<AsyncChangeStream<DocumentT,CompactChangeEvent<DocumentT>>>
watchCompact(BsonValue... ids)
Watches specified IDs in a collection.Task<AsyncChangeStream<DocumentT,CompactChangeEvent<DocumentT>>>
watchCompact(ObjectId... ids)
Watches specified IDs in a collection.Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>>
watchWithFilter(BsonDocument matchFilter)
Watches a collection.Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>>
watchWithFilter(Document matchFilter)
Watches a collection.RemoteMongoCollection<DocumentT>
withCodecRegistry(CodecRegistry codecRegistry)
Create a new RemoteMongoCollection instance with a different codec registry.<NewDocumentT>
RemoteMongoCollection<NewDocumentT>withDocumentClass(Class<NewDocumentT> clazz)
Create a new RemoteMongoCollection instance with a different default class to cast any documents returned from the database into.
-
-
-
Method Detail
-
getNamespace
MongoNamespace getNamespace()
Gets the namespace of this collection, i.e. the database and collection names together.- Returns:
- the namespace
-
getDocumentClass
Class<DocumentT> getDocumentClass()
Get the class of documents stored in this collection.If you used the simple
RemoteMongoDatabase.getCollection(String)
to get this collection, this isDocument
.- Returns:
- the class
-
getCodecRegistry
CodecRegistry getCodecRegistry()
Get the codec registry for the RemoteMongoCollection.- Returns:
- the
CodecRegistry
-
withDocumentClass
<NewDocumentT> RemoteMongoCollection<NewDocumentT> withDocumentClass(Class<NewDocumentT> clazz)
Create a new RemoteMongoCollection instance with a different default class to cast any documents returned from the database into.- Type Parameters:
NewDocumentT
- The type that the new collection will encode documents from and decode documents to.- Parameters:
clazz
- the default class to cast any documents returned from the database into.- Returns:
- a new RemoteMongoCollection instance with the different default class
-
withCodecRegistry
RemoteMongoCollection<DocumentT> withCodecRegistry(CodecRegistry codecRegistry)
Create a new RemoteMongoCollection instance with a different codec registry.- Parameters:
codecRegistry
- the newCodecRegistry
for the collection.- Returns:
- a new RemoteMongoCollection instance with the different codec registry
-
count
Task<Long> count()
Counts the number of documents in the collection.- Example:
// Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Count all documents movieDetails.count().addOnCompleteListener(new OnCompleteListener<Long>() { @Override public void onComplete(@android.support.annotation.NonNull Task<Long> task) { if (!task.isSuccessful()) { Log.e(TAG, "Count failed", task.getException()); return; } Log.i(TAG, "Count is " + task.getResult()); } });
- Returns:
- a task containing the number of documents in the collection
-
count
Task<Long> count(Bson filter)
Counts the number of documents in the collection according to the given options.- Example:
// Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Count all documents where title matches a regex movieDetails.count(new Document().append("title", new BsonRegularExpression("Star Wars"))).addOnCompleteListener(new OnCompleteListener<Long>() { @Override public void onComplete(@android.support.annotation.NonNull Task<Long> task) { if (!task.isSuccessful()) { Log.e(TAG, "Count failed", task.getException()); return; } Log.i(TAG, "Count is " + task.getResult()); } });
- Parameters:
filter
- the query filter- Returns:
- a task containing the number of documents in the collection
-
count
Task<Long> count(Bson filter, RemoteCountOptions options)
Counts the number of documents in the collection according to the given options.- Example:
// Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Count all documents where title matches a regex up to a limit movieDetails.count( new Document().append("title", new BsonRegularExpression("^A")), new RemoteCountOptions().limit(25)).addOnCompleteListener(new OnCompleteListener<Long>() { @Override public void onComplete(@android.support.annotation.NonNull Task<Long> task) { if (!task.isSuccessful()) { Log.e(TAG, "Count failed", task.getException()); return; } Log.i(TAG, "Count is " + task.getResult()); } });
- Parameters:
filter
- the query filteroptions
- the options describing the count- Returns:
- a task containing the number of documents in the collection
-
findOne
Task<DocumentT> findOne()
Finds a document in the collection.- Returns:
- a task containing the result of the find one operation
-
findOne
<ResultT> Task<ResultT> findOne(Class<ResultT> resultClass)
Finds a document in the collection.- Type Parameters:
ResultT
- the target document type- Parameters:
resultClass
- the class to decode each document into- Returns:
- a task containing the result of the find one operation
-
findOne
Task<DocumentT> findOne(Bson filter)
Finds a document in the collection.- Parameters:
filter
- the query filter- Returns:
- a task containing the result of the find one operation
-
findOne
<ResultT> Task<ResultT> findOne(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document into- Returns:
- a task containing the result of the find one operation
-
findOne
Task<DocumentT> findOne(Bson filter, RemoteFindOptions options)
Finds a document in the collection.- Parameters:
filter
- the query filteroptions
- A RemoteFindOptions struct- Returns:
- a task containing the result of the find one operation
-
findOne
<ResultT> Task<ResultT> findOne(Bson filter, RemoteFindOptions options, Class<ResultT> resultClass)
Finds a document in the collection.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filteroptions
- A RemoteFindOptions structresultClass
- the class to decode each document into- Returns:
- a task containing the result of the find one operation
-
find
RemoteFindIterable<DocumentT> find()
Finds all documents in the collection.- Example:
// Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Find 20 documents movieDetails.find().limit(20).forEach(document -> { Log.i(TAG, "Found document: " + document.toString()); });
- Returns:
- the find iterable interface
-
find
<ResultT> RemoteFindIterable<ResultT> find(Class<ResultT> resultClass)
Finds all documents in the collection.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
resultClass
- the class to decode each document into- Returns:
- the find iterable interface
-
find
RemoteFindIterable<DocumentT> find(Bson filter)
Finds all documents in the collection that match the given filter.- Example:
// Get the Atlas client. RemoteMongoClient mongoClient = appClient.getServiceClient(RemoteMongoClient.factory, "mongodb-atlas"); RemoteMongoDatabase db = mongoClient.getDatabase("video"); RemoteMongoCollection<Document> movieDetails = db.getCollection("movieDetails"); // Find up to 20 documents that match the title regex movieDetails.find(new Document().append("title", new BsonRegularExpression("Star Wars"))) .limit(20) .forEach(document -> { Log.i(TAG, "Found document: " + document.toString()); });
- Parameters:
filter
- the query filter- Returns:
- the find iterable interface
-
find
<ResultT> RemoteFindIterable<ResultT> find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection that match the given filter.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document into- Returns:
- the find iterable interface
-
aggregate
RemoteAggregateIterable<DocumentT> aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.- Parameters:
pipeline
- the aggregation pipeline- Returns:
- an iterable containing the result of the aggregation operation
-
aggregate
<ResultT> RemoteAggregateIterable<ResultT> aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents according to the specified aggregation pipeline.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
pipeline
- the aggregation pipelineresultClass
- the class to decode each document into- Returns:
- an iterable containing the result of the aggregation operation
-
insertOne
Task<RemoteInsertOneResult> insertOne(DocumentT document)
Inserts the provided document. If the document is missing an identifier, the client should generate one.- Parameters:
document
- the document to insert- Returns:
- a task containing the result of the insert one operation
-
insertMany
Task<RemoteInsertManyResult> insertMany(List<? extends DocumentT> documents)
Inserts one or more documents.- Parameters:
documents
- the documents to insert- Returns:
- a task containing the result of the insert many operation
-
deleteOne
Task<RemoteDeleteResult> deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- a task containing the result of the remove one operation
-
deleteMany
Task<RemoteDeleteResult> deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified.- Parameters:
filter
- the query filter to apply the the delete operation- Returns:
- a task containing the result of the remove many operation
-
updateOne
Task<RemoteUpdateResult> updateOne(Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- a task containing the result of the update one operation
-
updateOne
Task<RemoteUpdateResult> updateOne(Bson filter, Bson update, RemoteUpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.- Example:
// Update one document and handle the result. // Document filterDoc = new Document("name", "board game"); Document updateDoc = new Document("$inc", new Document("quantity", 5)); RemoteUpdateOptions options = new RemoteUpdateOptions().upsert(true); final Task <RemoteUpdateResult> updateTask = itemsCollection.updateOne(filterDoc, updateDoc, options); updateTask.addOnCompleteListener(new OnCompleteListener <RemoteUpdateResult> () { @Override public void onComplete(@NonNull Task <RemoteUpdateResult> task) { if (task.isSuccessful()) { if (task.getResult().getUpsertedId() != null) { String upsertedId = task.getResult().getUpsertedId().toString(); Log.d("app", String.format("successfully upserted document with id: %s", upsertedId)); } else { long numMatched = task.getResult().getMatchedCount(); long numModified = task.getResult().getModifiedCount(); Log.d("app", String.format("successfully matched %d and modified %d documents", numMatched, numModified)); } } else { Log.e("app", "failed to update document with: ", task.getException()); } } });
- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operation- Returns:
- a task containing the result of the update one operation
-
updateMany
Task<RemoteUpdateResult> updateMany(Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.- Returns:
- a task containing the result of the update many operation
-
updateMany
Task<RemoteUpdateResult> updateMany(Bson filter, Bson update, RemoteUpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.- Parameters:
filter
- a document describing the query filter, which may not be null.update
- a document describing the update, which may not be null. The update to apply must include only update operators.updateOptions
- the options to apply to the update operation- Returns:
- a task containing the result of the update many operation
-
findOneAndUpdate
Task<DocumentT> findOneAndUpdate(Bson filter, Bson update)
Finds a document in the collection and performs the given update.- Parameters:
filter
- the query filterupdate
- the update document- Returns:
- a task containing the resulting document
-
findOneAndUpdate
<ResultT> Task<ResultT> findOneAndUpdate(Bson filter, Bson update, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterupdate
- the update documentresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndUpdate
Task<DocumentT> findOneAndUpdate(Bson filter, Bson update, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and performs the given update.- Parameters:
filter
- the query filterupdate
- the update documentoptions
- A RemoteFindOneAndModifyOptions struct- Returns:
- a task containing the resulting document
-
findOneAndUpdate
<ResultT> Task<ResultT> findOneAndUpdate(Bson filter, Bson update, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterupdate
- the update documentoptions
- A RemoteFindOneAndModifyOptions structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndReplace
Task<DocumentT> findOneAndReplace(Bson filter, Bson replacement)
Finds a document in the collection and replaces it with the given document.- Parameters:
filter
- the query filterreplacement
- the document to replace the matched document with- Returns:
- a task containing the resulting document
-
findOneAndReplace
<ResultT> Task<ResultT> findOneAndReplace(Bson filter, Bson replacement, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterreplacement
- the document to replace the matched document withresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndReplace
Task<DocumentT> findOneAndReplace(Bson filter, Bson replacement, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and replaces it with the given document.- Parameters:
filter
- the query filterreplacement
- the document to replace the matched document withoptions
- A RemoteFindOneAndModifyOptions struct- Returns:
- a task containing the resulting document
-
findOneAndReplace
<ResultT> Task<ResultT> findOneAndReplace(Bson filter, Bson replacement, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterreplacement
- the document to replace the matched document withoptions
- A RemoteFindOneAndModifyOptions structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndDelete
Task<DocumentT> findOneAndDelete(Bson filter)
Finds a document in the collection and delete it.- Parameters:
filter
- the query filter- Returns:
- a task containing the resulting document
-
findOneAndDelete
<ResultT> Task<ResultT> findOneAndDelete(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection and delete it.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndDelete
Task<DocumentT> findOneAndDelete(Bson filter, RemoteFindOneAndModifyOptions options)
Finds a document in the collection and delete it.- Parameters:
filter
- the query filteroptions
- A RemoteFindOneAndModifyOptions struct- Returns:
- a task containing the resulting document
-
findOneAndDelete
<ResultT> Task<ResultT> findOneAndDelete(Bson filter, RemoteFindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and delete it.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filteroptions
- A RemoteFindOneAndModifyOptions structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
watch
Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>> watch()
Watches a collection. The resulting stream will be notified of all events on this collection that the active user is authorized to see based on the configured MongoDB rules.- Returns:
- the stream of change events.
-
watch
Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>> watch(ObjectId... ids)
Watches specified IDs in a collection. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
.- Parameters:
ids
- unique object identifiers of the IDs to watch.- Returns:
- the stream of change events.
-
watch
Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>> watch(BsonValue... ids)
Watches specified IDs in a collection.- Parameters:
ids
- the ids to watch.- Returns:
- the stream of change events.
-
watchWithFilter
Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>> watchWithFilter(BsonDocument matchFilter)
Watches a collection. The provided BSON document will be used as a match expression filter on the change events coming from the stream. See https://docs.mongodb.com/manual/reference/operator/aggregation/match/ for documentation around how to define a match filter. Defining the match expression to filter ChangeEvents is similar to defining the match expression for triggers: https://docs.mongodb.com/stitch/triggers/database-triggers/- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- the stream of change events.
-
watchWithFilter
Task<AsyncChangeStream<DocumentT,ChangeEvent<DocumentT>>> watchWithFilter(Document matchFilter)
Watches a collection. The provided BSON document will be used as a match expression filter on the change events coming from the stream. See https://docs.mongodb.com/manual/reference/operator/aggregation/match/ for documentation around how to define a match filter. Defining the match expression to filter ChangeEvents is similar to defining the match expression for triggers: https://docs.mongodb.com/stitch/triggers/database-triggers/- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- the stream of change events.
-
watchCompact
Task<AsyncChangeStream<DocumentT,CompactChangeEvent<DocumentT>>> watchCompact(ObjectId... ids)
Watches specified IDs in a collection. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
. Requests a stream where the full document of update events, and several other unnecessary fields are omitted from the change event objects returned by the server. This can save on network usage when watching large documents.- Parameters:
ids
- unique object identifiers of the IDs to watch.- Returns:
- the stream of change events.
-
watchCompact
Task<AsyncChangeStream<DocumentT,CompactChangeEvent<DocumentT>>> watchCompact(BsonValue... ids)
Watches specified IDs in a collection. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
. Requests a stream where the full document of update events, and several other unnecessary fields are omitted from the change event objects returned by the server. This can save on network usage when watching large documents.- Parameters:
ids
- the ids to watch.- Returns:
- the stream of change events.
-
-