Class MongoCollection<DocumentT>
- java.lang.Object
-
- io.realm.mongodb.mongo.MongoCollection<DocumentT>
-
- Type Parameters:
DocumentT
- The type that this collection will encode documents from and decode documents to.
public class MongoCollection<DocumentT> extends Object
The MongoCollection interface provides read and write access to documents.Use
MongoDatabase.getCollection(java.lang.String)
to get a collection instance.Before any access is possible, there must be an active, logged-in user.
- See Also:
MongoDatabase
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AggregateIterable<DocumentT>
aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.<ResultT> AggregateIterable<ResultT>
aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents according to the specified aggregation pipeline specifying an output class.RealmResultTask<Long>
count()
Counts the number of documents in the collection.RealmResultTask<Long>
count(Bson filter)
Counts the number of documents in the collection according to the given options.RealmResultTask<Long>
count(Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.RealmResultTask<DeleteResult>
deleteMany(Bson filter)
Removes all documents from the collection that match the given query filter.RealmResultTask<DeleteResult>
deleteOne(Bson filter)
Removes at most one document from the collection that matches the given filter.FindIterable<DocumentT>
find()
Finds all documents in the collection.FindIterable<DocumentT>
find(FindOptions options)
Finds all documents in the collection usingFindOptions
to build the query.<ResultT> FindIterable<ResultT>
find(Class<ResultT> resultClass)
Finds all documents in the collection specifying an output class.<ResultT> FindIterable<ResultT>
find(Class<ResultT> resultClass, FindOptions options)
Finds all documents in the collection specifying an output class and also usingFindOptions
to build the query.FindIterable<DocumentT>
find(Bson filter)
Finds all documents in the collection that match the given filter.FindIterable<DocumentT>
find(Bson filter, FindOptions options)
Finds all documents in the collection that match the given filter usingFindOptions
to build the query.<ResultT> FindIterable<ResultT>
find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection that match the given filter specifying an output class.<ResultT> FindIterable<ResultT>
find(Bson filter, Class<ResultT> resultClass, FindOptions options)
Finds all documents in the collection that match the given filter specifying an output class and also usingFindOptions
to build the query.RealmResultTask<DocumentT>
findOne()
Finds a document in the collection.<ResultT> RealmResultTask<ResultT>
findOne(Class<ResultT> resultClass)
Finds a document in the collection.RealmResultTask<DocumentT>
findOne(Bson filter)
Finds a document in the collection.RealmResultTask<DocumentT>
findOne(Bson filter, FindOptions options)
Finds a document in the collection.<ResultT> RealmResultTask<ResultT>
findOne(Bson filter, FindOptions options, Class<ResultT> resultClass)
Finds a document in the collection.<ResultT> RealmResultTask<ResultT>
findOne(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection.RealmResultTask<DocumentT>
findOneAndDelete(Bson filter)
Finds a document in the collection and delete it.RealmResultTask<DocumentT>
findOneAndDelete(Bson filter, FindOneAndModifyOptions options)
Finds a document in the collection and delete it.<ResultT> RealmResultTask<ResultT>
findOneAndDelete(Bson filter, FindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and delete it.<ResultT> RealmResultTask<ResultT>
findOneAndDelete(Bson filter, Class<ResultT> resultClass)
Finds a document in the collection and delete it.RealmResultTask<DocumentT>
findOneAndReplace(Bson filter, Bson replacement)
Finds a document in the collection and replaces it with the given document.RealmResultTask<DocumentT>
findOneAndReplace(Bson filter, Bson replacement, FindOneAndModifyOptions options)
Finds a document in the collection and replaces it with the given document.<ResultT> RealmResultTask<ResultT>
findOneAndReplace(Bson filter, Bson replacement, FindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.<ResultT> RealmResultTask<ResultT>
findOneAndReplace(Bson filter, Bson replacement, Class<ResultT> resultClass)
Finds a document in the collection and replaces it with the given document.RealmResultTask<DocumentT>
findOneAndUpdate(Bson filter, Bson update)
Finds a document in the collection and performs the given update.RealmResultTask<DocumentT>
findOneAndUpdate(Bson filter, Bson update, FindOneAndModifyOptions options)
Finds a document in the collection and performs the given update.<ResultT> RealmResultTask<ResultT>
findOneAndUpdate(Bson filter, Bson update, FindOneAndModifyOptions options, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.<ResultT> RealmResultTask<ResultT>
findOneAndUpdate(Bson filter, Bson update, Class<ResultT> resultClass)
Finds a document in the collection and performs the given update.CodecRegistry
getCodecRegistry()
Gets the codec registry for the MongoCollection.Class<DocumentT>
getDocumentClass()
Gets the class of documents stored in this collection.String
getName()
Gets the name of this collectionMongoNamespace
getNamespace()
Gets the namespace of this collection, i.e.RealmResultTask<InsertManyResult>
insertMany(List<? extends DocumentT> documents)
Inserts one or more documents.RealmResultTask<InsertOneResult>
insertOne(DocumentT document)
Inserts the provided document.RealmResultTask<UpdateResult>
updateMany(Bson filter, Bson update)
Update all documents in the collection according to the specified arguments.RealmResultTask<UpdateResult>
updateMany(Bson filter, Bson update, UpdateOptions updateOptions)
Update all documents in the collection according to the specified arguments.RealmResultTask<UpdateResult>
updateOne(Bson filter, Bson update)
Update a single document in the collection according to the specified arguments.RealmResultTask<UpdateResult>
updateOne(Bson filter, Bson update, UpdateOptions updateOptions)
Update a single document in the collection according to the specified arguments.RealmEventStreamTask<DocumentT>
watch()
Watches a collection.RealmEventStreamTask<DocumentT>
watch(BsonValue... ids)
Watches specified IDs in a collection.RealmEventStreamTask<DocumentT>
watch(ObjectId... ids)
Watches specified IDs in a collection.RealmEventStreamAsyncTask<DocumentT>
watchAsync()
Watches a collection asynchronously.RealmEventStreamAsyncTask<DocumentT>
watchAsync(BsonValue... ids)
Watches specified IDs in a collection asynchronously.RealmEventStreamAsyncTask<DocumentT>
watchAsync(ObjectId... ids)
Watches specified IDs in a collection asynchronously.RealmEventStreamTask<DocumentT>
watchWithFilter(BsonDocument matchFilter)
Watches a collection.RealmEventStreamTask<DocumentT>
watchWithFilter(Document matchFilter)
Watches a collection.RealmEventStreamAsyncTask<DocumentT>
watchWithFilterAsync(BsonDocument matchFilter)
Watches a collection asynchronously.RealmEventStreamAsyncTask<DocumentT>
watchWithFilterAsync(Document matchFilter)
Watches a collection asynchronously.MongoCollection<DocumentT>
withCodecRegistry(CodecRegistry codecRegistry)
Creates a new MongoCollection instance with a different codec registry.<NewDocumentT>
MongoCollection<NewDocumentT>withDocumentClass(Class<NewDocumentT> clazz)
Creates a new MongoCollection instance with a different default class to cast any documents returned from the database into.
-
-
-
Method Detail
-
getNamespace
public MongoNamespace getNamespace()
Gets the namespace of this collection, i.e. the database and collection names together.- Returns:
- the namespace
-
getName
public String getName()
Gets the name of this collection- Returns:
- the name
-
getDocumentClass
public Class<DocumentT> getDocumentClass()
Gets the class of documents stored in this collection.If you used the simple
MongoDatabase.getCollection(String)
to get this collection, this isDocument
.- Returns:
- the class of documents in this collection
-
getCodecRegistry
public CodecRegistry getCodecRegistry()
Gets the codec registry for the MongoCollection.- Returns:
- the
CodecRegistry
for this collection
-
withDocumentClass
public <NewDocumentT> MongoCollection<NewDocumentT> withDocumentClass(Class<NewDocumentT> clazz)
Creates a new MongoCollection 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 which any documents returned from the database will be cast.- Returns:
- a new MongoCollection instance with the different default class
-
withCodecRegistry
public MongoCollection<DocumentT> withCodecRegistry(CodecRegistry codecRegistry)
Creates a new MongoCollection instance with a different codec registry.- Parameters:
codecRegistry
- the newCodecRegistry
for the collection.- Returns:
- a new MongoCollection instance with the different codec registry
-
count
public RealmResultTask<Long> count()
Counts the number of documents in the collection.- Returns:
- a task containing the number of documents in the collection
-
count
public RealmResultTask<Long> count(Bson filter)
Counts the number of documents in the collection according to the given options.- Parameters:
filter
- the query filter- Returns:
- a task containing the number of documents in the collection
-
count
public RealmResultTask<Long> count(Bson filter, CountOptions options)
Counts the number of documents in the collection according to the given options.- Parameters:
filter
- the query filteroptions
- the options describing the count- Returns:
- a task containing the number of documents in the collection
-
findOne
public RealmResultTask<DocumentT> findOne()
Finds a document in the collection.- Returns:
- a task containing the result of the find one operation
-
findOne
public <ResultT> RealmResultTask<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
public RealmResultTask<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
public <ResultT> RealmResultTask<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
public RealmResultTask<DocumentT> findOne(Bson filter, FindOptions options)
Finds a document in the collection.- Parameters:
filter
- the query filteroptions
- aFindOptions
struct- Returns:
- a task containing the result of the find one operation
-
findOne
public <ResultT> RealmResultTask<ResultT> findOne(Bson filter, FindOptions 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
- aFindOptions
structresultClass
- the class to decode each document into- Returns:
- a task containing the result of the find one operation
-
find
public FindIterable<DocumentT> find()
Finds all documents in the collection.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Returns:
- an iterable containing the result of the find operation
-
find
public FindIterable<DocumentT> find(FindOptions options)
Finds all documents in the collection usingFindOptions
to build the query.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Parameters:
options
- aFindOptions
struct for building the query- Returns:
- an iterable containing the result of the find operation
-
find
public <ResultT> FindIterable<ResultT> find(Class<ResultT> resultClass)
Finds all documents in the collection specifying an output class.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
resultClass
- the class to decode each document into- Returns:
- an iterable containing the result of the find operation
-
find
public <ResultT> FindIterable<ResultT> find(Class<ResultT> resultClass, FindOptions options)
Finds all documents in the collection specifying an output class and also usingFindOptions
to build the query.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
resultClass
- the class to decode each document intooptions
- aFindOptions
struct for building the query- Returns:
- an iterable containing the result of the find operation
-
find
public FindIterable<DocumentT> find(Bson filter)
Finds all documents in the collection that match the given filter.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Parameters:
filter
- the query filter- Returns:
- an iterable containing the result of the find operation
-
find
public FindIterable<DocumentT> find(Bson filter, FindOptions options)
Finds all documents in the collection that match the given filter usingFindOptions
to build the query.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Parameters:
filter
- the query filteroptions
- aFindOptions
struct- Returns:
- an iterable containing the result of the find operation
-
find
public <ResultT> FindIterable<ResultT> find(Bson filter, Class<ResultT> resultClass)
Finds all documents in the collection that match the given filter specifying an output class.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document into- Returns:
- an iterable containing the result of the find operation
-
find
public <ResultT> FindIterable<ResultT> find(Bson filter, Class<ResultT> resultClass, FindOptions options)
Finds all documents in the collection that match the given filter specifying an output class and also usingFindOptions
to build the query.All documents will be delivered in the form of a
FindIterable
from which individual elements can be extracted.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
filter
- the query filterresultClass
- the class to decode each document intooptions
- aFindOptions
struct- Returns:
- an iterable containing the result of the find operation
-
aggregate
public AggregateIterable<DocumentT> aggregate(List<? extends Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.All documents will be delivered in the form of an
AggregateIterable
from which individual elements can be extracted.- Parameters:
pipeline
- the aggregation pipeline- Returns:
- an
AggregateIterable
from which the results can be extracted
-
aggregate
public <ResultT> AggregateIterable<ResultT> aggregate(List<? extends Bson> pipeline, Class<ResultT> resultClass)
Aggregates documents according to the specified aggregation pipeline specifying an output class.All documents will be delivered in the form of an
AggregateIterable
from which individual elements can be extracted.- Type Parameters:
ResultT
- the target document type of the iterable.- Parameters:
pipeline
- the aggregation pipelineresultClass
- the class to decode each document into- Returns:
- an
AggregateIterable
from which the results can be extracted
-
insertOne
public RealmResultTask<InsertOneResult> 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
public RealmResultTask<InsertManyResult> 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
public RealmResultTask<DeleteResult> 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
public RealmResultTask<DeleteResult> 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
public RealmResultTask<UpdateResult> 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
public RealmResultTask<UpdateResult> updateOne(Bson filter, Bson update, UpdateOptions updateOptions)
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.updateOptions
- the options to apply to the update operation- Returns:
- a task containing the result of the update one operation
-
updateMany
public RealmResultTask<UpdateResult> 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
public RealmResultTask<UpdateResult> updateMany(Bson filter, Bson update, UpdateOptions 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
public RealmResultTask<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
public <ResultT> RealmResultTask<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
public RealmResultTask<DocumentT> findOneAndUpdate(Bson filter, Bson update, FindOneAndModifyOptions options)
Finds a document in the collection and performs the given update.- Parameters:
filter
- the query filterupdate
- the update documentoptions
- aFindOneAndModifyOptions
struct- Returns:
- a task containing the resulting document
-
findOneAndUpdate
public <ResultT> RealmResultTask<ResultT> findOneAndUpdate(Bson filter, Bson update, FindOneAndModifyOptions 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
- aFindOneAndModifyOptions
structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndReplace
public RealmResultTask<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
public <ResultT> RealmResultTask<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
public RealmResultTask<DocumentT> findOneAndReplace(Bson filter, Bson replacement, FindOneAndModifyOptions 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
- aFindOneAndModifyOptions
struct- Returns:
- a task containing the resulting document
-
findOneAndReplace
public <ResultT> RealmResultTask<ResultT> findOneAndReplace(Bson filter, Bson replacement, FindOneAndModifyOptions 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
- aFindOneAndModifyOptions
structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
findOneAndDelete
public RealmResultTask<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
public <ResultT> RealmResultTask<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
public RealmResultTask<DocumentT> findOneAndDelete(Bson filter, FindOneAndModifyOptions options)
Finds a document in the collection and delete it.- Parameters:
filter
- the query filteroptions
- aFindOneAndModifyOptions
struct- Returns:
- a task containing the resulting document
-
findOneAndDelete
public <ResultT> RealmResultTask<ResultT> findOneAndDelete(Bson filter, FindOneAndModifyOptions 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
- aFindOneAndModifyOptions
structresultClass
- the class to decode each document into- Returns:
- a task containing the resulting document
-
watch
public RealmEventStreamTask<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 Realm rules.- Returns:
- a task that provides access to the stream of change events.
-
watch
public RealmEventStreamTask<DocumentT> watch(BsonValue... ids)
Watches specified IDs in a collection.- Parameters:
ids
- the ids to watch.- Returns:
- a task that provides access to the stream of change events.
-
watch
public RealmEventStreamTask<DocumentT> watch(ObjectId... ids)
Watches specified IDs in a collection. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
by wrapping them inBsonObjectId
instances for the user.- Parameters:
ids
- unique object identifiers of the IDs to watch.- Returns:
- a task that provides access to the stream of change events.
-
watchWithFilter
public RealmEventStreamTask<DocumentT> watchWithFilter(Document matchFilter)
Watches a collection. The provided document will be used as a match expression filter on the change events coming from the stream. This convenience overload supports the use of non-BsonDocument
instances for the user.See how to define a match filter.
Defining the match expression to filter ChangeEvents is similar to how to define the match expression for triggers
- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- a task that provides access to the stream of change events.
-
watchWithFilter
public RealmEventStreamTask<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 how to define a match filter.
Defining the match expression to filter ChangeEvents is similar to how to define the match expression for triggers
- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- a task that provides access to the stream of change events.
-
watchAsync
public RealmEventStreamAsyncTask<DocumentT> watchAsync()
Watches a collection asynchronously. 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 Realm rules.- Returns:
- a task that provides access to the stream of change events.
-
watchAsync
public RealmEventStreamAsyncTask<DocumentT> watchAsync(BsonValue... ids)
Watches specified IDs in a collection asynchronously.- Parameters:
ids
- the ids to watch.- Returns:
- a task that provides access to the stream of change events.
-
watchAsync
public RealmEventStreamAsyncTask<DocumentT> watchAsync(ObjectId... ids)
Watches specified IDs in a collection asynchronously. This convenience overload supports the use case of non-BsonValue
instances ofObjectId
by wrapping them inBsonObjectId
instances for the user.- Parameters:
ids
- unique object identifiers of the IDs to watch.- Returns:
- a task that provides access to the stream of change events.
-
watchWithFilterAsync
public RealmEventStreamAsyncTask<DocumentT> watchWithFilterAsync(Document matchFilter)
Watches a collection asynchronously. The provided document will be used as a match expression filter on the change events coming from the stream. This convenience overload supports the use of non-BsonDocument
instances for the user.See how to define a match filter.
Defining the match expression to filter ChangeEvents is similar to how to define the match expression for triggers
- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- a task that provides access to the stream of change events.
-
watchWithFilterAsync
public RealmEventStreamAsyncTask<DocumentT> watchWithFilterAsync(BsonDocument matchFilter)
Watches a collection asynchronously. The provided BSON document will be used as a match expression filter on the change events coming from the stream.See how to define a match filter.
Defining the match expression to filter ChangeEvents is similar to how to define the match expression for triggers
- Parameters:
matchFilter
- the $match filter to apply to incoming change events- Returns:
- a task that provides access to the stream of change events.
-
-