Class MongoCollection
On this page
- io.realm.mongodb.mongo
- Method Summary
- Inherited Methods
- Method Detail
- aggregate
- count
- deleteMany
- deleteOne
- find
- findOne
- findOneAndDelete
- findOneAndReplace
- findOneAndUpdate
- getCodecRegistry
- getDocumentClass
- getName
- getNamespace
- insertMany
- insertOne
- updateMany
- updateOne
- watch
- watchAsync
- watchWithFilter
- watchWithFilterAsync
- withCodecRegistry
- withDocumentClass
io.realm.mongodb.mongo
The MongoCollection interface provides read and write access to documents.Use MongoDatabase.getCollection to get a collection instance.
Before any access is possible, there must be an active, logged-in user.
Method Summary
Modifier and Type | Method and Description |
---|---|
public AggregateIterable | Aggregates documents according to the specified aggregation pipeline specifying an output class. |
public AggregateIterable | Aggregates documents according to the specified aggregation pipeline. |
public RealmResultTask | Counts the number of documents in the collection according to the given options. |
public RealmResultTask | Counts the number of documents in the collection according to the given options. |
public RealmResultTask | count () Counts the number of documents in the collection. |
public RealmResultTask | Removes all documents from the collection that match the given query filter. |
public RealmResultTask | Removes at most one document from the collection that matches the given filter. |
public FindIterable | Finds all documents in the collection that match the given filter specifying an output class and also using FindOptions to build the query. |
public FindIterable | Finds all documents in the collection that match the given filter specifying an output class. |
public FindIterable | Finds all documents in the collection that match the given filter using FindOptions to build the query. |
public FindIterable | Finds all documents in the collection that match the given filter. |
public FindIterable | Finds all documents in the collection specifying an output class and also using FindOptions to build the query. |
public FindIterable | Finds all documents in the collection specifying an output class. |
public FindIterable | Finds all documents in the collection using FindOptions to build the query. |
public FindIterable | find () Finds all documents in the collection. |
public RealmResultTask | Finds a document in the collection. |
public RealmResultTask | Finds a document in the collection. |
public RealmResultTask | Finds a document in the collection. |
public RealmResultTask | Finds a document in the collection. |
public RealmResultTask | Finds a document in the collection. |
public RealmResultTask | findOne () Finds a document in the collection. |
public RealmResultTask | findOneAndDelete <ResultT >( ) Finds a document in the collection and delete it. |
public RealmResultTask | Finds a document in the collection and delete it. |
public RealmResultTask | Finds a document in the collection and delete it. |
public RealmResultTask | Finds a document in the collection and delete it. |
public RealmResultTask | findOneAndReplace <ResultT >( ) Finds a document in the collection and replaces it with the given document. |
public RealmResultTask | Finds a document in the collection and replaces it with the given document. |
public RealmResultTask | Finds a document in the collection and replaces it with the given document. |
public RealmResultTask | Finds a document in the collection and replaces it with the given document. |
public RealmResultTask | findOneAndUpdate <ResultT >( ) Finds a document in the collection and performs the given update. |
public RealmResultTask | Finds a document in the collection and performs the given update. |
public RealmResultTask | Finds a document in the collection and performs the given update. |
public RealmResultTask | Finds a document in the collection and performs the given update. |
public CodecRegistry | Gets the codec registry for the MongoCollection. |
public Class | Gets the class of documents stored in this collection. |
public String | getName () Gets the name of this collection |
public MongoNamespace | getNamespace () Gets the namespace of this collection, i.e. |
public RealmResultTask | Inserts one or more documents. |
public RealmResultTask | Inserts the provided document. |
public RealmResultTask | Update all documents in the collection according to the specified arguments. |
public RealmResultTask | Update all documents in the collection according to the specified arguments. |
public RealmResultTask | Update a single document in the collection according to the specified arguments. |
public RealmResultTask | Update a single document in the collection according to the specified arguments. |
public RealmEventStreamTask | Watches specified IDs in a collection. |
public RealmEventStreamTask | Watches specified IDs in a collection. |
public RealmEventStreamTask | watch () Watches a collection. |
public RealmEventStreamAsyncTask | Watches specified IDs in a collection asynchronously. |
public RealmEventStreamAsyncTask | Watches specified IDs in a collection asynchronously. |
public RealmEventStreamAsyncTask | watchAsync () Watches a collection asynchronously. |
public RealmEventStreamTask | Watches a collection. |
public RealmEventStreamTask | Watches a collection. |
public RealmEventStreamAsyncTask | Watches a collection asynchronously. |
public RealmEventStreamAsyncTask | Watches a collection asynchronously. |
public MongoCollection | Creates a new MongoCollection instance with a different codec registry. |
public MongoCollection | Creates a new MongoCollection instance with a different default class to cast any documents returned from the database into. |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
aggregate
public AggregateIterable aggregate <ResultT >( java.util.List<? extends Bson> pipeline, java.lang.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
Parameters
Returns an AggregateIterable from which the results can be extracted |
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
Returns an AggregateIterable from which the results can be extracted |
count
Counts the number of documents in the collection according to the given options. Parameters
Returns a task containing the number of documents in the collection |
Counts the number of documents in the collection according to the given options. Parameters
Returns a task containing the number of documents in the collection |
public RealmResultTask count () |
---|
Counts the number of documents in the collection. Returns a task containing the number of documents in the collection |
deleteMany
Removes all documents from the collection that match the given query filter. If no documents match, the collection is not modified. Parameters
Returns a task containing the result of the remove many operation |
deleteOne
Removes at most one document from the collection that matches the given filter. If no documents match, the collection is not modified. Parameters
Returns a task containing the result of the remove one operation |
find
public FindIterable find <ResultT >( ) |
---|
Finds all documents in the collection that match the given filter specifying an output class and also using FindOptions to build the query. All documents will be delivered in the form of a FindIterable from which individual elements can be extracted. Type Parameters
Parameters
Returns an iterable containing the result of the find operation |
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
Parameters
Returns an iterable containing the result of the find operation |
Finds all documents in the collection that match the given filter using FindOptions to build the query. All documents will be delivered in the form of a FindIterable from which individual elements can be extracted. Parameters
Returns an iterable containing the result of the find operation |
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
Returns an iterable containing the result of the find operation |
Finds all documents in the collection specifying an output class and also using FindOptions to build the query. All documents will be delivered in the form of a FindIterable from which individual elements can be extracted. Type Parameters
Parameters
Returns an iterable containing the result of the find operation |
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
Parameters
Returns an iterable containing the result of the find operation |
Finds all documents in the collection using FindOptions to build the query. All documents will be delivered in the form of a FindIterable from which individual elements can be extracted. Parameters
Returns an iterable containing the result of the find operation |
public FindIterable 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 |
findOne
public RealmResultTask findOne <ResultT >( ) |
---|
Finds a document in the collection. Type Parameters
Parameters
Returns a task containing the result of the find one operation |
Finds a document in the collection. Parameters
Returns a task containing the result of the find one operation |
Finds a document in the collection. Type Parameters
Parameters
Returns a task containing the result of the find one operation |
Finds a document in the collection. Parameters
Returns a task containing the result of the find one operation |
Finds a document in the collection. Type Parameters
Parameters
Returns a task containing the result of the find one operation |
public RealmResultTask findOne () |
---|
Finds a document in the collection. Returns a task containing the result of the find one operation |
findOneAndDelete
public RealmResultTask findOneAndDelete <ResultT >( ) |
---|
Finds a document in the collection and delete it. Type Parameters
Parameters
Returns a task containing the resulting document |
Finds a document in the collection and delete it. Parameters
Returns a task containing the resulting document |
public RealmResultTask findOneAndDelete <ResultT >( Bson filter, java.lang.Class<ResultT> resultClass ) |
---|
Finds a document in the collection and delete it. Type Parameters
Parameters
Returns a task containing the resulting document |
Finds a document in the collection and delete it. Parameters
Returns a task containing the resulting document |
findOneAndReplace
public RealmResultTask findOneAndReplace <ResultT >( ) |
---|
Finds a document in the collection and replaces it with the given document. Type Parameters
Parameters
Returns a task containing the resulting document |
public RealmResultTask findOneAndReplace ( ) |
---|
Finds a document in the collection and replaces it with the given document. Parameters
Returns a task containing the resulting document |
public RealmResultTask findOneAndReplace <ResultT >( ) |
---|
Finds a document in the collection and replaces it with the given document. Type Parameters
Parameters
Returns a task containing the resulting document |
Finds a document in the collection and replaces it with the given document. Parameters
Returns a task containing the resulting document |
findOneAndUpdate
public RealmResultTask findOneAndUpdate <ResultT >( ) |
---|
Finds a document in the collection and performs the given update. Type Parameters
Parameters
Returns a task containing the resulting document |
Finds a document in the collection and performs the given update. Parameters
Returns a task containing the resulting document |
public RealmResultTask findOneAndUpdate <ResultT >( ) |
---|
Finds a document in the collection and performs the given update. Type Parameters
Parameters
Returns a task containing the resulting document |
Finds a document in the collection and performs the given update. Parameters
Returns a task containing the resulting document |
getCodecRegistry
public CodecRegistry getCodecRegistry () |
---|
Gets the codec registry for the MongoCollection. Returns the CodecRegistry for this collection |
getDocumentClass
public Class getDocumentClass () |
---|
Gets the class of documents stored in this collection.If you used the simple MongoDatabase.getCollection(String) to get this collection, this is org.bson.Document . Returns the class of documents in this collection |
getName
getNamespace
public MongoNamespace getNamespace () |
---|
Gets the namespace of this collection, i.e. the database and collection names together. Returns the namespace |
insertMany
Inserts one or more documents. Parameters
Returns a task containing the result of the insert many operation |
insertOne
Inserts the provided document. If the document is missing an identifier, the client should generate one. Parameters
Returns a task containing the result of the insert one operation |
updateMany
Update all documents in the collection according to the specified arguments. Parameters
Returns a task containing the result of the update many operation |
Update all documents in the collection according to the specified arguments. Parameters
Returns a task containing the result of the update many operation |
updateOne
Update a single document in the collection according to the specified arguments. Parameters
Returns a task containing the result of the update one operation |
Update a single document in the collection according to the specified arguments. Parameters
Returns a task containing the result of the update one operation |
watch
Watches specified IDs in a collection. This convenience overload supports the use case of non-BsonValue instances of ObjectId by wrapping them in BsonObjectId instances for the user. Parameters
Returns a task that provides access to the stream of change events. |
Watches specified IDs in a collection. Parameters
Returns a task that provides access to the stream of change events. |
public RealmEventStreamTask 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. |
watchAsync
Watches specified IDs in a collection asynchronously. This convenience overload supports the use case of non-BsonValue instances of ObjectId by wrapping them in BsonObjectId instances for the user. Parameters
Returns a task that provides access to the stream of change events. |
Watches specified IDs in a collection asynchronously. Parameters
Returns a task that provides access to the stream of change events. |
public RealmEventStreamAsyncTask 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. |
watchWithFilter
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
Returns a task that provides access to the stream of change events. |
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
Returns a task that provides access to the stream of change events. |
watchWithFilterAsync
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
Returns a task that provides access to the stream of change events. |
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
Returns a task that provides access to the stream of change events. |
withCodecRegistry
Creates a new MongoCollection instance with a different codec registry. Parameters
Returns a new MongoCollection instance with the different codec registry |
withDocumentClass
Creates a new MongoCollection instance with a different default class to cast any documents returned from the database into. Type Parameters
Parameters
Returns a new MongoCollection instance with the different default class |