TDocument
- The type that this collection will encode documents from and decode documents to.@ThreadSafe
public interface MongoCollection<TDocument>
Note: Additions to this interface will not be considered to break binary compatibility.
Modifier and Type | Method and Description |
---|---|
AggregateObservable<org.bson.Document> |
aggregate(List<? extends org.bson.conversions.Bson> pipeline)
Aggregates documents according to the specified aggregation pipeline.
|
<TResult> AggregateObservable<TResult> |
aggregate(List<? extends org.bson.conversions.Bson> pipeline,
Class<TResult> clazz)
Aggregates documents according to the specified aggregation pipeline.
|
rx.Observable<com.mongodb.bulk.BulkWriteResult> |
bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests)
Executes a mix of inserts, updates, replaces, and deletes.
|
rx.Observable<com.mongodb.bulk.BulkWriteResult> |
bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests,
com.mongodb.client.model.BulkWriteOptions options)
Executes a mix of inserts, updates, replaces, and deletes.
|
rx.Observable<Long> |
count()
Counts the number of documents in the collection.
|
rx.Observable<Long> |
count(org.bson.conversions.Bson filter)
Counts the number of documents in the collection according to the given options.
|
rx.Observable<Long> |
count(org.bson.conversions.Bson filter,
com.mongodb.client.model.CountOptions options)
Counts the number of documents in the collection according to the given options.
|
rx.Observable<String> |
createIndex(org.bson.conversions.Bson key)
Creates an index.
|
rx.Observable<String> |
createIndex(org.bson.conversions.Bson key,
com.mongodb.client.model.IndexOptions options)
Creates an index.
|
rx.Observable<String> |
createIndexes(List<com.mongodb.client.model.IndexModel> indexes)
Create multiple indexes.
|
rx.Observable<com.mongodb.client.result.DeleteResult> |
deleteMany(org.bson.conversions.Bson filter)
Removes all documents from the collection that match the given query filter.
|
rx.Observable<com.mongodb.client.result.DeleteResult> |
deleteMany(org.bson.conversions.Bson filter,
com.mongodb.client.model.DeleteOptions options)
Removes all documents from the collection that match the given query filter.
|
rx.Observable<com.mongodb.client.result.DeleteResult> |
deleteOne(org.bson.conversions.Bson filter)
Removes at most one document from the collection that matches the given filter.
|
rx.Observable<com.mongodb.client.result.DeleteResult> |
deleteOne(org.bson.conversions.Bson filter,
com.mongodb.client.model.DeleteOptions options)
Removes at most one document from the collection that matches the given filter.
|
<TResult> DistinctObservable<TResult> |
distinct(String fieldName,
org.bson.conversions.Bson filter,
Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
<TResult> DistinctObservable<TResult> |
distinct(String fieldName,
Class<TResult> resultClass)
Gets the distinct values of the specified field name.
|
rx.Observable<Success> |
drop()
Drops this collection from the Database.
|
rx.Observable<Success> |
dropIndex(org.bson.conversions.Bson keys)
Drops the index given the keys used to create it.
|
rx.Observable<Success> |
dropIndex(String indexName)
Drops the given index.
|
rx.Observable<Success> |
dropIndexes()
Drop all the indexes on this collection, except for the default on _id.
|
FindObservable<TDocument> |
find()
Finds all documents in the collection.
|
FindObservable<TDocument> |
find(org.bson.conversions.Bson filter)
Finds all documents in the collection.
|
<TResult> FindObservable<TResult> |
find(org.bson.conversions.Bson filter,
Class<TResult> clazz)
Finds all documents in the collection.
|
<TResult> FindObservable<TResult> |
find(Class<TResult> clazz)
Finds all documents in the collection.
|
rx.Observable<TDocument> |
findOneAndDelete(org.bson.conversions.Bson filter)
Atomically find a document and remove it.
|
rx.Observable<TDocument> |
findOneAndDelete(org.bson.conversions.Bson filter,
com.mongodb.client.model.FindOneAndDeleteOptions options)
Atomically find a document and remove it.
|
rx.Observable<TDocument> |
findOneAndReplace(org.bson.conversions.Bson filter,
TDocument replacement)
Atomically find a document and replace it.
|
rx.Observable<TDocument> |
findOneAndReplace(org.bson.conversions.Bson filter,
TDocument replacement,
com.mongodb.client.model.FindOneAndReplaceOptions options)
Atomically find a document and replace it.
|
rx.Observable<TDocument> |
findOneAndUpdate(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update)
Atomically find a document and update it.
|
rx.Observable<TDocument> |
findOneAndUpdate(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.FindOneAndUpdateOptions options)
Atomically find a document and update it.
|
org.bson.codecs.configuration.CodecRegistry |
getCodecRegistry()
Get the codec registry for the MongoCollection.
|
Class<TDocument> |
getDocumentClass()
Get the class of documents stored in this collection.
|
com.mongodb.MongoNamespace |
getNamespace()
Gets the namespace of this collection.
|
ObservableAdapter |
getObservableAdapter()
Get the ObservableAdapter for this collection.
|
com.mongodb.ReadConcern |
getReadConcern()
Get the read concern for the MongoCollection.
|
com.mongodb.ReadPreference |
getReadPreference()
Get the read preference for the MongoCollection.
|
com.mongodb.WriteConcern |
getWriteConcern()
Get the write concern for the MongoCollection.
|
rx.Observable<Success> |
insertMany(List<? extends TDocument> documents)
Inserts a batch of documents.
|
rx.Observable<Success> |
insertMany(List<? extends TDocument> documents,
com.mongodb.client.model.InsertManyOptions options)
Inserts a batch of documents.
|
rx.Observable<Success> |
insertOne(TDocument document)
Inserts the provided document.
|
rx.Observable<Success> |
insertOne(TDocument document,
com.mongodb.client.model.InsertOneOptions options)
Inserts the provided document.
|
ListIndexesObservable<org.bson.Document> |
listIndexes()
Get all the indexes in this collection.
|
<TResult> ListIndexesObservable<TResult> |
listIndexes(Class<TResult> clazz)
Get all the indexes in this collection.
|
MapReduceObservable<org.bson.Document> |
mapReduce(String mapFunction,
String reduceFunction)
Aggregates documents according to the specified map-reduce function.
|
<TResult> MapReduceObservable<TResult> |
mapReduce(String mapFunction,
String reduceFunction,
Class<TResult> clazz)
Aggregates documents according to the specified map-reduce function.
|
rx.Observable<Success> |
renameCollection(com.mongodb.MongoNamespace newCollectionNamespace)
Rename the collection with oldCollectionName to the newCollectionName.
|
rx.Observable<Success> |
renameCollection(com.mongodb.MongoNamespace newCollectionNamespace,
com.mongodb.client.model.RenameCollectionOptions options)
Rename the collection with oldCollectionName to the newCollectionName.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
replaceOne(org.bson.conversions.Bson filter,
TDocument replacement)
Replace a document in the collection according to the specified arguments.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
replaceOne(org.bson.conversions.Bson filter,
TDocument replacement,
com.mongodb.client.model.UpdateOptions options)
Replace a document in the collection according to the specified arguments.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
updateMany(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update)
Update all documents in the collection according to the specified arguments.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
updateMany(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.UpdateOptions options)
Update all documents in the collection according to the specified arguments.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
updateOne(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update)
Update a single document in the collection according to the specified arguments.
|
rx.Observable<com.mongodb.client.result.UpdateResult> |
updateOne(org.bson.conversions.Bson filter,
org.bson.conversions.Bson update,
com.mongodb.client.model.UpdateOptions options)
Update a single document in the collection according to the specified arguments.
|
MongoCollection<TDocument> |
withCodecRegistry(org.bson.codecs.configuration.CodecRegistry codecRegistry)
Create a new MongoCollection instance with a different codec registry.
|
<NewTDocument> |
withDocumentClass(Class<NewTDocument> clazz)
Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..
|
MongoCollection<TDocument> |
withObservableAdapter(ObservableAdapter observableAdapter)
Create a new MongoCollection instance with a different
ObservableAdapter . |
MongoCollection<TDocument> |
withReadConcern(com.mongodb.ReadConcern readConcern)
Create a new MongoCollection instance with a different read concern.
|
MongoCollection<TDocument> |
withReadPreference(com.mongodb.ReadPreference readPreference)
Create a new MongoCollection instance with a different read preference.
|
MongoCollection<TDocument> |
withWriteConcern(com.mongodb.WriteConcern writeConcern)
Create a new MongoCollection instance with a different write concern.
|
com.mongodb.MongoNamespace getNamespace()
Class<TDocument> getDocumentClass()
ObservableAdapter getObservableAdapter()
ObservableAdapter
org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
CodecRegistry
com.mongodb.ReadPreference getReadPreference()
ReadPreference
com.mongodb.WriteConcern getWriteConcern()
WriteConcern
com.mongodb.ReadConcern getReadConcern()
ReadConcern
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz)
NewTDocument
- The type that the new collection will encode documents from and decode documents toclazz
- the default class to cast any documents returned from the database into.MongoCollection<TDocument> withCodecRegistry(org.bson.codecs.configuration.CodecRegistry codecRegistry)
codecRegistry
- the new CodecRegistry
for the collectionMongoCollection<TDocument> withReadPreference(com.mongodb.ReadPreference readPreference)
readPreference
- the new ReadPreference
for the collectionMongoCollection<TDocument> withWriteConcern(com.mongodb.WriteConcern writeConcern)
writeConcern
- the new WriteConcern
for the collectionMongoCollection<TDocument> withReadConcern(com.mongodb.ReadConcern readConcern)
readConcern
- the new ReadConcern
for the collectionMongoCollection<TDocument> withObservableAdapter(ObservableAdapter observableAdapter)
ObservableAdapter
.observableAdapter
- the new ObservableAdapter
for the collectionrx.Observable<Long> count()
rx.Observable<Long> count(org.bson.conversions.Bson filter)
filter
- the query filterrx.Observable<Long> count(org.bson.conversions.Bson filter, com.mongodb.client.model.CountOptions options)
filter
- the query filteroptions
- the options describing the count<TResult> DistinctObservable<TResult> distinct(String fieldName, Class<TResult> resultClass)
TResult
- the target type of the iterable.fieldName
- the field nameresultClass
- the default class to cast any distinct items into.<TResult> DistinctObservable<TResult> distinct(String fieldName, org.bson.conversions.Bson filter, Class<TResult> resultClass)
TResult
- the target type of the iterable.fieldName
- the field namefilter
- the query filterresultClass
- the default class to cast any distinct items into.FindObservable<TDocument> find()
<TResult> FindObservable<TResult> find(Class<TResult> clazz)
TResult
- the target document type of the iterable.clazz
- the class to decode each document intoFindObservable<TDocument> find(org.bson.conversions.Bson filter)
filter
- the query filter<TResult> FindObservable<TResult> find(org.bson.conversions.Bson filter, Class<TResult> clazz)
TResult
- the target document type of the iterable.filter
- the query filterclazz
- the class to decode each document intoAggregateObservable<org.bson.Document> aggregate(List<? extends org.bson.conversions.Bson> pipeline)
pipeline
- the aggregate pipeline<TResult> AggregateObservable<TResult> aggregate(List<? extends org.bson.conversions.Bson> pipeline, Class<TResult> clazz)
TResult
- the target document type of the iterable.pipeline
- the aggregate pipelineclazz
- the class to decode each document intoMapReduceObservable<org.bson.Document> mapReduce(String mapFunction, String reduceFunction)
mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.<TResult> MapReduceObservable<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> clazz)
TResult
- the target document type of the iterable.mapFunction
- A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduceFunction
- A JavaScript function that "reduces" to a single object all the values associated with a particular key.clazz
- the class to decode each resulting document into.rx.Observable<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests)
requests
- the writes to executerx.Observable<com.mongodb.bulk.BulkWriteResult> bulkWrite(List<? extends com.mongodb.client.model.WriteModel<? extends TDocument>> requests, com.mongodb.client.model.BulkWriteOptions options)
requests
- the writes to executeoptions
- the options to apply to the bulk write operationrx.Observable<Success> insertOne(TDocument document)
document
- the document to insertrx.Observable<Success> insertOne(TDocument document, com.mongodb.client.model.InsertOneOptions options)
document
- the document to insertoptions
- the options to apply to the operationrx.Observable<Success> insertMany(List<? extends TDocument> documents)
documents
- the documents to insertrx.Observable<Success> insertMany(List<? extends TDocument> documents, com.mongodb.client.model.InsertManyOptions options)
documents
- the documents to insertoptions
- the options to apply to the operationrx.Observable<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter)
filter
- the query filter to apply the the delete operationrx.Observable<com.mongodb.client.result.DeleteResult> deleteOne(org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationrx.Observable<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter)
filter
- the query filter to apply the the delete operationrx.Observable<com.mongodb.client.result.DeleteResult> deleteMany(org.bson.conversions.Bson filter, com.mongodb.client.model.DeleteOptions options)
filter
- the query filter to apply the the delete operationoptions
- the options to apply to the delete operationrx.Observable<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter, TDocument replacement)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentrx.Observable<com.mongodb.client.result.UpdateResult> replaceOne(org.bson.conversions.Bson filter, TDocument replacement, com.mongodb.client.model.UpdateOptions options)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the replace operationrx.Observable<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
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.rx.Observable<com.mongodb.client.result.UpdateResult> updateOne(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions options)
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.options
- the options to apply to the update operationrx.Observable<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
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.rx.Observable<com.mongodb.client.result.UpdateResult> updateMany(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.UpdateOptions options)
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.options
- the options to apply to the update operationrx.Observable<TDocument> findOneAndDelete(org.bson.conversions.Bson filter)
filter
- the query filter to find the document withrx.Observable<TDocument> findOneAndDelete(org.bson.conversions.Bson filter, com.mongodb.client.model.FindOneAndDeleteOptions options)
filter
- the query filter to find the document withoptions
- the options to apply to the operationrx.Observable<TDocument> findOneAndReplace(org.bson.conversions.Bson filter, TDocument replacement)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentreturnOriginal
property, this will either be the document as it was before the update or as it is after the update. If no documents matched the
query filter, then the observer will complete without emitting any itemsrx.Observable<TDocument> findOneAndReplace(org.bson.conversions.Bson filter, TDocument replacement, com.mongodb.client.model.FindOneAndReplaceOptions options)
filter
- the query filter to apply the the replace operationreplacement
- the replacement documentoptions
- the options to apply to the operationreturnOriginal
property, this will either be the document as it was before the update or as it is after the update.
If no documents matched the query filter, then the observer will complete without emitting any itemsrx.Observable<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
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.rx.Observable<TDocument> findOneAndUpdate(org.bson.conversions.Bson filter, org.bson.conversions.Bson update, com.mongodb.client.model.FindOneAndUpdateOptions options)
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.options
- the options to apply to the operationreturnOriginal
property, this will either be the document as it was before the update or as it is after the update.
If no documents matched the query filter, then the observer will complete without emitting any itemsrx.Observable<Success> drop()
rx.Observable<String> createIndex(org.bson.conversions.Bson key)
key
- an object describing the index key(s), which may not be null.rx.Observable<String> createIndex(org.bson.conversions.Bson key, com.mongodb.client.model.IndexOptions options)
key
- an object describing the index key(s), which may not be null.options
- the options for the indexrx.Observable<String> createIndexes(List<com.mongodb.client.model.IndexModel> indexes)
indexes
- the list of indexesListIndexesObservable<org.bson.Document> listIndexes()
<TResult> ListIndexesObservable<TResult> listIndexes(Class<TResult> clazz)
TResult
- the target document type of the iterable.clazz
- the class to decode each document intorx.Observable<Success> dropIndex(String indexName)
indexName
- the name of the index to removerx.Observable<Success> dropIndex(org.bson.conversions.Bson keys)
keys
- the keys of the index to removerx.Observable<Success> dropIndexes()
rx.Observable<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace)
newCollectionNamespace
- the namespace the collection will be renamed torx.Observable<Success> renameCollection(com.mongodb.MongoNamespace newCollectionNamespace, com.mongodb.client.model.RenameCollectionOptions options)
newCollectionNamespace
- the name the collection will be renamed tooptions
- the options for renaming a collection