public class ReactiveMongoTemplate extends Object implements ReactiveMongoOperations, ApplicationContextAware
ReactiveMongoOperations. It simplifies the use of Reactive MongoDB usage and helps
to avoid common errors. It executes core MongoDB workflow, leaving application code to provide Document and
extract results. This class executes BSON queries or updates, initiating iteration over FindPublisher and
catching MongoDB exceptions and translating them to the generic, more informative exception hierarchy defined in the
org.springframework.dao package. Can be used within a service implementation via direct instantiation with a
SimpleReactiveMongoDatabaseFactory reference, or get prepared in an application context and given to services
as bean reference. Note: The SimpleReactiveMongoDatabaseFactory should always be configured as a bean in the
application context, in the first case given to the service directly, in the second case to the prepared template.ReactiveFindOperation.FindWithCollection<T>, ReactiveFindOperation.FindWithProjection<T>, ReactiveFindOperation.FindWithQuery<T>, ReactiveFindOperation.ReactiveFind<T>, ReactiveFindOperation.TerminatingFind<T>, ReactiveFindOperation.TerminatingFindNear<T>ReactiveInsertOperation.InsertWithCollection<T>, ReactiveInsertOperation.ReactiveInsert<T>, ReactiveInsertOperation.TerminatingInsert<T>ReactiveUpdateOperation.FindAndModifyWithOptions<T>, ReactiveUpdateOperation.ReactiveUpdate<T>, ReactiveUpdateOperation.TerminatingFindAndModify<T>, ReactiveUpdateOperation.TerminatingUpdate<T>, ReactiveUpdateOperation.UpdateWithCollection<T>, ReactiveUpdateOperation.UpdateWithQuery<T>, ReactiveUpdateOperation.UpdateWithUpdate<T>ReactiveRemoveOperation.ReactiveRemove<T>, ReactiveRemoveOperation.RemoveWithCollection<T>, ReactiveRemoveOperation.RemoveWithQuery<T>, ReactiveRemoveOperation.TerminatingRemove<T>ReactiveAggregationOperation.AggregationOperationWithAggregation<T>, ReactiveAggregationOperation.AggregationOperationWithCollection<T>, ReactiveAggregationOperation.ReactiveAggregation<T>, ReactiveAggregationOperation.TerminatingAggregationOperation<T>| Modifier and Type | Field and Description |
|---|---|
static DbRefResolver |
NO_OP_REF_RESOLVER |
| Constructor and Description |
|---|
ReactiveMongoTemplate(com.mongodb.reactivestreams.client.MongoClient mongoClient,
String databaseName)
Constructor used for a basic template configuration.
|
ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory)
Constructor used for a basic template configuration.
|
ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory,
MongoConverter mongoConverter)
Constructor used for a basic template configuration.
|
| Modifier and Type | Method and Description |
|---|---|
<O> reactor.core.publisher.Flux<O> |
aggregate(Aggregation aggregation,
Class<?> inputType,
Class<O> outputType)
Execute an aggregation operation.
|
<O> reactor.core.publisher.Flux<O> |
aggregate(Aggregation aggregation,
String collectionName,
Class<O> outputType)
Execute an aggregation operation.
|
protected <O> reactor.core.publisher.Flux<O> |
aggregate(Aggregation aggregation,
String collectionName,
Class<O> outputType,
AggregationOperationContext context) |
<O> reactor.core.publisher.Flux<O> |
aggregate(TypedAggregation<?> aggregation,
Class<O> outputType)
Execute an aggregation operation.
|
<O> reactor.core.publisher.Flux<O> |
aggregate(TypedAggregation<?> aggregation,
String inputCollectionName,
Class<O> outputType)
Execute an aggregation operation.
|
<T> ReactiveAggregationOperation.ReactiveAggregation<T> |
aggregateAndReturn(Class<T> domainType)
Start creating an aggregation operation that returns results mapped to the given domain type.
|
<T> reactor.core.publisher.Mono<Boolean> |
collectionExists(Class<T> entityClass)
Check to see if a collection with a name indicated by the entity class exists.
|
reactor.core.publisher.Mono<Boolean> |
collectionExists(String collectionName)
Check to see if a collection with a given name exists.
|
protected com.mongodb.client.model.CreateCollectionOptions |
convertToCreateCollectionOptions(CollectionOptions collectionOptions) |
reactor.core.publisher.Mono<Long> |
count(Query query,
Class<?> entityClass)
Returns the number of documents for the given
Query by querying the collection of the given entity class. |
reactor.core.publisher.Mono<Long> |
count(Query query,
Class<?> entityClass,
String collectionName)
|
reactor.core.publisher.Mono<Long> |
count(Query query,
String collectionName)
Returns the number of documents for the given
Query querying the given collection. |
<T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> |
createCollection(Class<T> entityClass)
Create an uncapped collection with a name based on the provided entity class.
|
<T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> |
createCollection(Class<T> entityClass,
CollectionOptions collectionOptions)
Create a collection with a name based on the provided entity class using the options.
|
reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> |
createCollection(String collectionName)
Create an uncapped collection with the provided name.
|
reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> |
createCollection(String collectionName,
CollectionOptions collectionOptions)
Create a collection with the provided name and options.
|
<T> reactor.core.publisher.Flux<T> |
createFlux(ReactiveDatabaseCallback<T> callback)
Create a reusable Flux for a
ReactiveDatabaseCallback. |
<T> reactor.core.publisher.Flux<T> |
createFlux(String collectionName,
ReactiveCollectionCallback<T> callback)
|
<T> reactor.core.publisher.Mono<T> |
createMono(ReactiveDatabaseCallback<T> callback)
Create a reusable Mono for a
ReactiveDatabaseCallback. |
<T> reactor.core.publisher.Mono<T> |
createMono(String collectionName,
ReactiveCollectionCallback<T> callback)
|
protected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> |
doCreateCollection(String collectionName,
com.mongodb.client.model.CreateCollectionOptions collectionOptions)
Create the specified collection using the provided options
|
protected <S,T> reactor.core.publisher.Flux<T> |
doFind(String collectionName,
org.bson.Document query,
org.bson.Document fields,
Class<S> entityClass,
org.springframework.data.mongodb.core.FindPublisherPreparer preparer,
org.springframework.data.mongodb.core.ReactiveMongoTemplate.DocumentCallback<T> objectCallback) |
protected <T> reactor.core.publisher.Flux<T> |
doFind(String collectionName,
org.bson.Document query,
org.bson.Document fields,
Class<T> entityClass)
Map the results of an ad-hoc query on the default MongoDB collection to a List using the template's converter.
|
protected <T> reactor.core.publisher.Flux<T> |
doFind(String collectionName,
org.bson.Document query,
org.bson.Document fields,
Class<T> entityClass,
org.springframework.data.mongodb.core.FindPublisherPreparer preparer)
Map the results of an ad-hoc query on the default MongoDB collection to a List of the specified type.
|
protected <T> reactor.core.publisher.Flux<T> |
doFindAndDelete(String collectionName,
Query query,
Class<T> entityClass)
Retrieve and remove all documents matching the given
query by calling find(Query, Class, String)
and remove(Query, Class, String), whereas the Query for remove(Query, Class, String) is
constructed out of the find result. |
protected <T> reactor.core.publisher.Mono<T> |
doFindAndModify(String collectionName,
org.bson.Document query,
org.bson.Document fields,
org.bson.Document sort,
Class<T> entityClass,
Update update,
FindAndModifyOptions options) |
protected <T> reactor.core.publisher.Mono<T> |
doFindAndRemove(String collectionName,
org.bson.Document query,
org.bson.Document fields,
org.bson.Document sort,
Collation collation,
Class<T> entityClass)
Map the results of an ad-hoc query on the default MongoDB collection to an object using the template's converter.
|
protected <T> reactor.core.publisher.Mono<T> |
doFindOne(String collectionName,
org.bson.Document query,
org.bson.Document fields,
Class<T> entityClass,
Collation collation)
Map the results of an ad-hoc query on the default MongoDB collection to an object using the template's converter.
|
protected <T> reactor.core.publisher.Mono<T> |
doInsert(String collectionName,
T objectToSave,
MongoWriter<Object> writer) |
protected <T> reactor.core.publisher.Flux<T> |
doInsertAll(Collection<? extends T> listToSave,
MongoWriter<Object> writer) |
protected <T> reactor.core.publisher.Flux<T> |
doInsertBatch(String collectionName,
Collection<? extends T> batchToSave,
MongoWriter<Object> writer) |
protected <T> reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
doRemove(String collectionName,
Query query,
Class<T> entityClass) |
protected <T> reactor.core.publisher.Mono<T> |
doSave(String collectionName,
T objectToSave,
MongoWriter<Object> writer) |
protected reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
doUpdate(String collectionName,
Query query,
Update update,
Class<?> entityClass,
boolean upsert,
boolean multi) |
<T> reactor.core.publisher.Mono<Void> |
dropCollection(Class<T> entityClass)
Drop the collection with the name indicated by the entity class.
|
reactor.core.publisher.Mono<Void> |
dropCollection(String collectionName)
Drop the collection with the given name.
|
protected void |
ensureNotIterable(Object o) |
<T> reactor.core.publisher.Flux<T> |
execute(Class<?> entityClass,
ReactiveCollectionCallback<T> action)
Executes the given
ReactiveCollectionCallback on the entity collection of the specified class. |
<T> reactor.core.publisher.Flux<T> |
execute(ReactiveDatabaseCallback<T> action)
Executes a
ReactiveDatabaseCallback translating any exceptions as necessary. |
<T> reactor.core.publisher.Flux<T> |
execute(String collectionName,
ReactiveCollectionCallback<T> callback)
Executes the given
ReactiveCollectionCallback on the collection of the given name. |
reactor.core.publisher.Mono<org.bson.Document> |
executeCommand(org.bson.Document command)
Execute a MongoDB command.
|
reactor.core.publisher.Mono<org.bson.Document> |
executeCommand(org.bson.Document command,
com.mongodb.ReadPreference readPreference)
Execute a MongoDB command.
|
reactor.core.publisher.Mono<org.bson.Document> |
executeCommand(String jsonCommand)
Execute the a MongoDB command expressed as a JSON string.
|
reactor.core.publisher.Mono<Boolean> |
exists(Query query,
Class<?> entityClass)
Determine result of given
Query contains at least one element. |
reactor.core.publisher.Mono<Boolean> |
exists(Query query,
Class<?> entityClass,
String collectionName)
Determine result of given
Query contains at least one element. |
reactor.core.publisher.Mono<Boolean> |
exists(Query query,
String collectionName)
Determine result of given
Query contains at least one element. |
<T> reactor.core.publisher.Flux<T> |
find(Query query,
Class<T> entityClass)
Map the results of an ad-hoc query on the collection for the entity class to a
Flux of the specified type. |
<T> reactor.core.publisher.Flux<T> |
find(Query query,
Class<T> entityClass,
String collectionName)
Map the results of an ad-hoc query on the specified collection to a
Flux of the specified type. |
<T> reactor.core.publisher.Flux<T> |
findAll(Class<T> entityClass)
Query for a
Flux of objects of type T from the collection used by the entity class. |
<T> reactor.core.publisher.Flux<T> |
findAll(Class<T> entityClass,
String collectionName)
Query for a
Flux of objects of type T from the specified collection. |
<T> reactor.core.publisher.Flux<T> |
findAllAndRemove(Query query,
Class<T> entityClass)
Returns and removes all documents matching the given query form the collection used to store the entityClass.
|
<T> reactor.core.publisher.Flux<T> |
findAllAndRemove(Query query,
Class<T> entityClass,
String collectionName)
Returns and removes all documents that match the provided query document criteria from the the collection used to
store the entityClass.
|
<T> reactor.core.publisher.Flux<T> |
findAllAndRemove(Query query,
String collectionName)
Returns and removes all documents form the specified collection that match the provided query.
|
<T> reactor.core.publisher.Mono<T> |
findAndModify(Query query,
Update update,
Class<T> entityClass)
|
<T> reactor.core.publisher.Mono<T> |
findAndModify(Query query,
Update update,
Class<T> entityClass,
String collectionName)
|
<T> reactor.core.publisher.Mono<T> |
findAndModify(Query query,
Update update,
FindAndModifyOptions options,
Class<T> entityClass)
Triggers findAndModify
to apply provided
Update on documents matching Criteria of given Query taking
FindAndModifyOptions into account. |
<T> reactor.core.publisher.Mono<T> |
findAndModify(Query query,
Update update,
FindAndModifyOptions options,
Class<T> entityClass,
String collectionName)
Triggers findAndModify
to apply provided
Update on documents matching Criteria of given Query taking
FindAndModifyOptions into account. |
<T> reactor.core.publisher.Mono<T> |
findAndRemove(Query query,
Class<T> entityClass)
Map the results of an ad-hoc query on the collection for the entity type to a single instance of an object of the
specified type.
|
<T> reactor.core.publisher.Mono<T> |
findAndRemove(Query query,
Class<T> entityClass,
String collectionName)
Map the results of an ad-hoc query on the specified collection to a single instance of an object of the specified
type.
|
<T> reactor.core.publisher.Mono<T> |
findById(Object id,
Class<T> entityClass)
Returns a document with the given id mapped onto the given class.
|
<T> reactor.core.publisher.Mono<T> |
findById(Object id,
Class<T> entityClass,
String collectionName)
Returns the document with the given id from the given collection mapped onto the given target class.
|
<T> reactor.core.publisher.Mono<T> |
findOne(Query query,
Class<T> entityClass)
Map the results of an ad-hoc query on the collection for the entity class to a single instance of an object of the
specified type.
|
<T> reactor.core.publisher.Mono<T> |
findOne(Query query,
Class<T> entityClass,
String collectionName)
Map the results of an ad-hoc query on the specified collection to a single instance of an object of the specified
type.
|
protected <T> reactor.core.publisher.Flux<GeoResult<T>> |
geoNear(NearQuery near,
Class<?> entityClass,
String collectionName,
Class<T> returnType) |
<T> reactor.core.publisher.Flux<GeoResult<T>> |
geoNear(NearQuery near,
Class<T> entityClass)
|
<T> reactor.core.publisher.Flux<GeoResult<T>> |
geoNear(NearQuery near,
Class<T> entityClass,
String collectionName)
|
com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> |
getCollection(String collectionName)
Get a collection by name, creating it if it doesn't exist.
|
String |
getCollectionName(Class<?> entityClass) |
reactor.core.publisher.Flux<String> |
getCollectionNames()
A set of collection names.
|
MongoConverter |
getConverter()
Returns the default
MongoConverter. |
com.mongodb.reactivestreams.client.MongoDatabase |
getMongoDatabase() |
ReactiveIndexOperations |
indexOps(Class<?> entityClass)
Returns the reactive operations that can be performed on indexes
|
ReactiveIndexOperations |
indexOps(String collectionName)
Returns the reactive operations that can be performed on indexes
|
<T> ReactiveInsertOperation.ReactiveInsert<T> |
insert(Class<T> domainType)
Start creating an insert operation for given domainType.
|
<T> reactor.core.publisher.Flux<T> |
insert(Collection<? extends T> batchToSave,
Class<?> entityClass)
Insert a Collection of objects into a collection in a single batch write to the database.
|
<T> reactor.core.publisher.Flux<T> |
insert(Collection<? extends T> batchToSave,
String collectionName)
Insert a batch of objects into the specified collection in a single batch write to the database.
|
<T> reactor.core.publisher.Mono<T> |
insert(reactor.core.publisher.Mono<? extends T> objectToSave)
Insert the object into the collection for the entity type of the object to save.
|
<T> reactor.core.publisher.Mono<T> |
insert(T objectToSave)
Insert the object into the collection for the entity type of the object to save.
|
<T> reactor.core.publisher.Mono<T> |
insert(T objectToSave,
String collectionName)
Insert the object into the specified collection.
|
<T> reactor.core.publisher.Flux<T> |
insertAll(Collection<? extends T> objectsToSave)
Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
class.
|
<T> reactor.core.publisher.Flux<T> |
insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> objectsToSave)
Insert a mixed Collection of objects into a database collection determining the collection name to use based on the
class.
|
<T> reactor.core.publisher.Flux<T> |
insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave,
Class<?> entityClass)
Insert a Collection of objects into a collection in a single batch write to the database.
|
<T> reactor.core.publisher.Flux<T> |
insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave,
String collectionName)
Insert objects into the specified collection in a single batch write to the database.
|
protected reactor.core.publisher.Mono<Object> |
insertDBObject(String collectionName,
org.bson.Document dbDoc,
Class<?> entityClass) |
protected reactor.core.publisher.Flux<org.bson.types.ObjectId> |
insertDocumentList(String collectionName,
List<org.bson.Document> dbDocList) |
protected <T> void |
maybeEmitEvent(MongoMappingEvent<T> event) |
protected com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> |
prepareCollection(com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> collection)
Prepare the collection before any processing is done using it.
|
protected com.mongodb.WriteConcern |
prepareWriteConcern(MongoAction mongoAction)
Prepare the WriteConcern before any processing is done using it.
|
<T> ReactiveFindOperation.ReactiveFind<T> |
query(Class<T> domainType)
Start creating a find operation for the given domainType.
|
<T> ReactiveRemoveOperation.ReactiveRemove<T> |
remove(Class<T> domainType)
Start creating a remove operation for the given domainType.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(reactor.core.publisher.Mono<? extends Object> objectToRemove)
Remove the given object from the collection by id.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(reactor.core.publisher.Mono<? extends Object> objectToRemove,
String collection)
Removes the given object from the given collection.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(Object object)
Remove the given object from the collection by id.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(Object object,
String collection)
Removes the given object from the given collection.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(Query query,
Class<?> entityClass)
Remove all documents that match the provided query document criteria from the the collection used to store the
entityClass.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(Query query,
Class<?> entityClass,
String collectionName)
Remove all documents that match the provided query document criteria from the the collection used to store the
entityClass.
|
reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> |
remove(Query query,
String collectionName)
Remove all documents from the specified collection that match the provided query document criteria.
|
<T> reactor.core.publisher.Mono<T> |
save(reactor.core.publisher.Mono<? extends T> objectToSave)
Save the object to the collection for the entity type of the object to save.
|
<T> reactor.core.publisher.Mono<T> |
save(reactor.core.publisher.Mono<? extends T> objectToSave,
String collectionName)
Save the object to the specified collection.
|
<T> reactor.core.publisher.Mono<T> |
save(T objectToSave)
Save the object to the collection for the entity type of the object to save.
|
<T> reactor.core.publisher.Mono<T> |
save(T objectToSave,
String collectionName)
Save the object to the specified collection.
|
protected reactor.core.publisher.Mono<Object> |
saveDocument(String collectionName,
org.bson.Document document,
Class<?> entityClass) |
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setReadPreference(com.mongodb.ReadPreference readPreference)
Used by @{link
prepareCollection(MongoCollection) to set the ReadPreference before any operations
are performed. |
void |
setWriteConcern(com.mongodb.WriteConcern writeConcern)
Configures the
WriteConcern to be used with the template. |
void |
setWriteConcernResolver(WriteConcernResolver writeConcernResolver)
Configures the
WriteConcernResolver to be used with the template. |
void |
setWriteResultChecking(WriteResultChecking resultChecking)
Configures the
WriteResultChecking to be used with the template. |
<T> reactor.core.publisher.Flux<T> |
tail(Query query,
Class<T> entityClass)
Map the results of an ad-hoc query on the collection for the entity class to a stream of objects of the specified
type.
|
<T> reactor.core.publisher.Flux<T> |
tail(Query query,
Class<T> entityClass,
String collectionName)
Map the results of an ad-hoc query on the collection for the entity class to a stream of objects of the specified
type.
|
<T> ReactiveUpdateOperation.ReactiveUpdate<T> |
update(Class<T> domainType)
Start creating an update operation for the given domainType.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateFirst(Query query,
Update update,
Class<?> entityClass)
Updates the first object that is found in the collection of the entity class that matches the query document with
the provided update document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateFirst(Query query,
Update update,
Class<?> entityClass,
String collectionName)
Updates the first object that is found in the specified collection that matches the query document criteria with
the provided updated document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateFirst(Query query,
Update update,
String collectionName)
Updates the first object that is found in the specified collection that matches the query document criteria with
the provided updated document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateMulti(Query query,
Update update,
Class<?> entityClass)
Updates all objects that are found in the collection for the entity class that matches the query document criteria
with the provided updated document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateMulti(Query query,
Update update,
Class<?> entityClass,
String collectionName)
Updates all objects that are found in the collection for the entity class that matches the query document criteria
with the provided updated document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
updateMulti(Query query,
Update update,
String collectionName)
Updates all objects that are found in the specified collection that matches the query document criteria with the
provided updated document.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
upsert(Query query,
Update update,
Class<?> entityClass)
Performs an upsert.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
upsert(Query query,
Update update,
Class<?> entityClass,
String collectionName)
Performs an upsert.
|
reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> |
upsert(Query query,
Update update,
String collectionName)
Performs an upsert.
|
public static final DbRefResolver NO_OP_REF_RESOLVER
public ReactiveMongoTemplate(com.mongodb.reactivestreams.client.MongoClient mongoClient,
String databaseName)
mongoClient - must not be null.databaseName - must not be null or empty.public ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory)
mongoDatabaseFactory - must not be null.public ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory, MongoConverter mongoConverter)
mongoDatabaseFactory - must not be null.mongoConverter - public void setWriteResultChecking(WriteResultChecking resultChecking)
WriteResultChecking to be used with the template. Setting null will reset the
default of DEFAULT_WRITE_RESULT_CHECKING.resultChecking - public void setWriteConcern(com.mongodb.WriteConcern writeConcern)
WriteConcern to be used with the template. If none is configured the WriteConcern
configured on the MongoDbFactory will apply. If you configured a Mongo instance no
WriteConcern will be used.writeConcern - public void setWriteConcernResolver(WriteConcernResolver writeConcernResolver)
WriteConcernResolver to be used with the template.writeConcernResolver - public void setReadPreference(com.mongodb.ReadPreference readPreference)
prepareCollection(MongoCollection) to set the ReadPreference before any operations
are performed.readPreference - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext in interface ApplicationContextAwareBeansExceptionpublic MongoConverter getConverter()
MongoConverter.getConverter in interface ReactiveMongoOperationspublic ReactiveIndexOperations indexOps(String collectionName)
ReactiveMongoOperationsindexOps in interface ReactiveMongoOperationspublic ReactiveIndexOperations indexOps(Class<?> entityClass)
ReactiveMongoOperationsindexOps in interface ReactiveMongoOperationspublic reactor.core.publisher.Mono<org.bson.Document> executeCommand(String jsonCommand)
ReactiveMongoOperationsexecuteCommand in interface ReactiveMongoOperationsjsonCommand - a MongoDB command expressed as a JSON string.public reactor.core.publisher.Mono<org.bson.Document> executeCommand(org.bson.Document command)
ReactiveMongoOperationsexecuteCommand in interface ReactiveMongoOperationscommand - a MongoDB commandpublic reactor.core.publisher.Mono<org.bson.Document> executeCommand(org.bson.Document command,
com.mongodb.ReadPreference readPreference)
ReactiveMongoOperationsexecuteCommand in interface ReactiveMongoOperationscommand - a MongoDB command, must not be null.readPreference - read preferences to use, can be null.public <T> reactor.core.publisher.Flux<T> execute(Class<?> entityClass, ReactiveCollectionCallback<T> action)
ReactiveMongoOperationsReactiveCollectionCallback on the entity collection of the specified class.
Allows for returning a result object, that is a domain object or a collection of domain objects.execute in interface ReactiveMongoOperationsT - return typeentityClass - class that determines the collection to useaction - callback object that specifies the MongoDB actionpublic <T> reactor.core.publisher.Flux<T> execute(ReactiveDatabaseCallback<T> action)
ReactiveMongoOperationsReactiveDatabaseCallback translating any exceptions as necessary.
Allows for returning a result object, that is a domain object or a collection of domain objects.execute in interface ReactiveMongoOperationsT - return typeaction - callback object that specifies the MongoDB actions to perform on the passed in DB instance.public <T> reactor.core.publisher.Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> callback)
ReactiveMongoOperationsReactiveCollectionCallback on the collection of the given name.
Allows for returning a result object, that is a domain object or a collection of domain objects.execute in interface ReactiveMongoOperationsT - return typecollectionName - the name of the collection that specifies which DBCollection instance will be passed intocallback - callback object that specifies the MongoDB action the callback action.public <T> reactor.core.publisher.Flux<T> createFlux(ReactiveDatabaseCallback<T> callback)
ReactiveDatabaseCallback. It's up to the developer to choose to obtain a new
Flux or to reuse the Flux.callback - must not be nullFlux wrapping the ReactiveDatabaseCallback.public <T> reactor.core.publisher.Mono<T> createMono(ReactiveDatabaseCallback<T> callback)
ReactiveDatabaseCallback. It's up to the developer to choose to obtain a new
Flux or to reuse the Flux.callback - must not be nullMono wrapping the ReactiveDatabaseCallback.public <T> reactor.core.publisher.Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<T> callback)
collectionName - must not be empty or null.callback - must not be null.Flux wrapping the ReactiveCollectionCallback.public <T> reactor.core.publisher.Mono<T> createMono(String collectionName, ReactiveCollectionCallback<T> callback)
T - collectionName - must not be empty or null.callback - must not be null.Mono wrapping the ReactiveCollectionCallback.public <T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(Class<T> entityClass)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationsentityClass - class that determines the collection to createpublic <T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(Class<T> entityClass, CollectionOptions collectionOptions)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationsentityClass - class that determines the collection to createcollectionOptions - options to use when creating the collection.public reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(String collectionName)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationscollectionName - name of the collectionpublic reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(String collectionName, CollectionOptions collectionOptions)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationscollectionName - name of the collectioncollectionOptions - options to use when creating the collection.public com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> getCollection(String collectionName)
ReactiveMongoOperationsgetCollection in interface ReactiveMongoOperationscollectionName - name of the collectionpublic <T> reactor.core.publisher.Mono<Boolean> collectionExists(Class<T> entityClass)
ReactiveMongoOperationscollectionExists in interface ReactiveMongoOperationsentityClass - class that determines the name of the collectionpublic reactor.core.publisher.Mono<Boolean> collectionExists(String collectionName)
ReactiveMongoOperationscollectionExists in interface ReactiveMongoOperationscollectionName - name of the collectionpublic <T> reactor.core.publisher.Mono<Void> dropCollection(Class<T> entityClass)
ReactiveMongoOperationsdropCollection in interface ReactiveMongoOperationsentityClass - class that determines the collection to drop/delete.public reactor.core.publisher.Mono<Void> dropCollection(String collectionName)
ReactiveMongoOperationsdropCollection in interface ReactiveMongoOperationscollectionName - name of the collection to drop/delete.public reactor.core.publisher.Flux<String> getCollectionNames()
ReactiveMongoOperationsgetCollectionNames in interface ReactiveMongoOperationspublic com.mongodb.reactivestreams.client.MongoDatabase getMongoDatabase()
public <T> reactor.core.publisher.Mono<T> findOne(Query query, Class<T> entityClass)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.findOne in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Mono.public <T> reactor.core.publisher.Mono<T> findOne(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.findOne in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Mono.collectionName - name of the collection to retrieve the objects frompublic reactor.core.publisher.Mono<Boolean> exists(Query query, Class<?> entityClass)
ReactiveMongoOperationsQuery contains at least one element.exists in interface ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find a record.entityClass - the parametrized type.public reactor.core.publisher.Mono<Boolean> exists(Query query, String collectionName)
ReactiveMongoOperationsQuery contains at least one element. ReactiveMongoOperations.exists(Query, Class, String) to get full type specific support.exists in interface ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find a record.collectionName - name of the collection to check for objects.public reactor.core.publisher.Mono<Boolean> exists(Query query, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsQuery contains at least one element.exists in interface ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find a record.entityClass - the parametrized type.collectionName - name of the collection to check for objects.public <T> reactor.core.publisher.Flux<T> find(Query query, Class<T> entityClass)
ReactiveMongoOperationsFlux of the specified type.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.find in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Flux.Flux of converted objectspublic <T> reactor.core.publisher.Flux<T> find(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsFlux of the specified type.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.find in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Flux.collectionName - name of the collection to retrieve the objects fromFlux of converted objectspublic <T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> entityClass)
ReactiveMongoOperationsfindById in interface ReactiveMongoOperationsid - the id of the document to return.entityClass - the type the document shall be converted into.public <T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsfindById in interface ReactiveMongoOperationsid - the id of the document to returnentityClass - the type to convert the document tocollectionName - the collection to query for the documentpublic <O> reactor.core.publisher.Flux<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType)
ReactiveMongoOperationsThe raw results will be mapped to the given entity class.
Aggregation streaming cannot be used with aggregation explain nor with
AggregationOptions.getCursorBatchSize(). Enabling explanation mode or setting batch size cause
IllegalArgumentException.
aggregate in interface ReactiveMongoOperationsaggregation - The TypedAggregation specification holding the aggregation operations. Must not be
null.inputCollectionName - The name of the input collection to use for the aggregation. Must not be null.outputType - The parametrized type of the returned Flux. Must not be null.public <O> reactor.core.publisher.Flux<O> aggregate(TypedAggregation<?> aggregation, Class<O> outputType)
ReactiveMongoOperationsaggregation input type.
Aggregation streaming cannot be used with aggregation explain nor with
AggregationOptions.getCursorBatchSize(). Enabling explanation mode or setting batch size cause
IllegalArgumentException.aggregate in interface ReactiveMongoOperationsaggregation - The TypedAggregation specification holding the aggregation operations. Must not be
null.outputType - The parametrized type of the returned Flux. Must not be null.public <O> reactor.core.publisher.Flux<O> aggregate(Aggregation aggregation, Class<?> inputType, Class<O> outputType)
ReactiveMongoOperationsouputType. The name of the inputCollection is derived from the
inputType.
Aggregation streaming cannot be used with aggregation explain nor with
AggregationOptions.getCursorBatchSize(). Enabling explanation mode or setting batch size cause
IllegalArgumentException.aggregate in interface ReactiveMongoOperationsaggregation - The Aggregation specification holding the aggregation operations. Must not be
null.inputType - the inputType where the aggregation operation will read from. Must not be null.outputType - The parametrized type of the returned Flux. Must not be null.public <O> reactor.core.publisher.Flux<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType)
ReactiveMongoOperationsaggregation explain nor with
AggregationOptions.getCursorBatchSize(). Enabling explanation mode or setting batch size cause
IllegalArgumentException.aggregate in interface ReactiveMongoOperationsaggregation - The Aggregation specification holding the aggregation operations. Must not be
null.collectionName - the collection where the aggregation operation will read from. Must not be null or
empty.outputType - The parametrized type of the returned Flux. Must not be null.protected <O> reactor.core.publisher.Flux<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType, AggregationOperationContext context)
aggregation - must not be null.collectionName - must not be null.outputType - must not be null.context - can be null and will be defaulted to Aggregation.DEFAULT_CONTEXT.public <T> reactor.core.publisher.Flux<GeoResult<T>> geoNear(NearQuery near, Class<T> entityClass)
ReactiveMongoOperationsFlux of GeoResult for all entities matching the given NearQuery. Will consider
entity mapping information to determine the collection the query is ran against. Note, that MongoDB limits the
number of results by default. Make sure to add an explicit limit to the NearQuery if you expect a
particular number of results.geoNear in interface ReactiveMongoOperationsnear - must not be null.entityClass - must not be null.public <T> reactor.core.publisher.Flux<GeoResult<T>> geoNear(NearQuery near, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsFlux of GeoResult for all entities matching the given NearQuery. Note, that MongoDB
limits the number of results by default. Make sure to add an explicit limit to the NearQuery if you expect
a particular number of results.geoNear in interface ReactiveMongoOperationsnear - must not be null.entityClass - must not be null.collectionName - the collection to trigger the query against. If no collection name is given the entity class
will be inspected.protected <T> reactor.core.publisher.Flux<GeoResult<T>> geoNear(NearQuery near, Class<?> entityClass, String collectionName, Class<T> returnType)
public <T> reactor.core.publisher.Mono<T> findAndModify(Query query, Update update, Class<T> entityClass)
ReactiveMongoOperationsfindAndModify in interface ReactiveMongoOperationsquery - the Query class that specifies the Criteria used to find a record and also an optional
fields specification.update - the Update to apply on matching documents.entityClass - the parametrized type.public <T> reactor.core.publisher.Mono<T> findAndModify(Query query, Update update, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsfindAndModify in interface ReactiveMongoOperationsquery - the Query class that specifies the Criteria used to find a record and also an optional
fields specification.update - the Update to apply on matching documents.entityClass - the parametrized type.collectionName - the collection to query.public <T> reactor.core.publisher.Mono<T> findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass)
ReactiveMongoOperationsUpdate on documents matching Criteria of given Query taking
FindAndModifyOptions into account.findAndModify in interface ReactiveMongoOperationsquery - the Query class that specifies the Criteria used to find a record and also an optional
fields specification.update - the Update to apply on matching documents.options - the FindAndModifyOptions holding additional information.entityClass - the parametrized type.public <T> reactor.core.publisher.Mono<T> findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsUpdate on documents matching Criteria of given Query taking
FindAndModifyOptions into account.findAndModify in interface ReactiveMongoOperationsquery - the Query class that specifies the Criteria used to find a record and also an optional
fields specification.update - the Update to apply on matching documents.options - the FindAndModifyOptions holding additional information.entityClass - the parametrized type.collectionName - the collection to query.public <T> reactor.core.publisher.Mono<T> findAndRemove(Query query, Class<T> entityClass)
ReactiveMongoOperationsMongoConverter.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.findAndRemove in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Mono.public <T> reactor.core.publisher.Mono<T> findAndRemove(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.findAndRemove in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Mono.collectionName - name of the collection to retrieve the objects from.public reactor.core.publisher.Mono<Long> count(Query query, Class<?> entityClass)
ReactiveMongoOperationsQuery by querying the collection of the given entity class.count in interface ReactiveMongoOperationsentityClass - must not be null.public reactor.core.publisher.Mono<Long> count(Query query, String collectionName)
ReactiveMongoOperationsQuery querying the given collection. The given Query
must solely consist of document field references as we lack type information to map potential property references
onto document fields. Use ReactiveMongoOperations.count(Query, Class, String) to get full type specific support.count in interface ReactiveMongoOperationscollectionName - must not be null or empty.ReactiveMongoOperations.count(Query, Class, String)public reactor.core.publisher.Mono<Long> count(Query query, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsQuery by querying the given collection using the given entity
class to map the given Query.count in interface ReactiveMongoOperationsentityClass - must not be null.collectionName - must not be null or empty.public <T> reactor.core.publisher.Mono<T> insert(reactor.core.publisher.Mono<? extends T> objectToSave)
ReactiveMongoOperationsMongoConverter.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
Spring's Type Conversion" for more details.
Insert is used to initially store the object into the database. To update an existing object use the save method.insert in interface ReactiveMongoOperationsobjectToSave - the object to store in the collection.public <T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave, Class<?> entityClass)
ReactiveMongoOperationsinsertAll in interface ReactiveMongoOperationsbatchToSave - the publisher which provides objects to save.entityClass - class that determines the collection to usepublic <T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave, String collectionName)
ReactiveMongoOperationsinsertAll in interface ReactiveMongoOperationsbatchToSave - the publisher which provides objects to save.collectionName - name of the collection to store the object inpublic <T> reactor.core.publisher.Mono<T> insert(T objectToSave)
ReactiveMongoOperationsMongoConverter.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
Spring's Type Conversion" for more details.
Insert is used to initially store the object into the database. To update an existing object use the save method.insert in interface ReactiveMongoOperationsobjectToSave - the object to store in the collection.public <T> reactor.core.publisher.Mono<T> insert(T objectToSave,
String collectionName)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
Insert is used to initially store the object into the database. To update an existing object use the save method.insert in interface ReactiveMongoOperationsobjectToSave - the object to store in the collectioncollectionName - name of the collection to store the object inprotected <T> reactor.core.publisher.Mono<T> doInsert(String collectionName, T objectToSave, MongoWriter<Object> writer)
public <T> reactor.core.publisher.Flux<T> insert(Collection<? extends T> batchToSave, Class<?> entityClass)
ReactiveMongoOperationsinsert in interface ReactiveMongoOperationsbatchToSave - the batch of objects to save.entityClass - class that determines the collection to usepublic <T> reactor.core.publisher.Flux<T> insert(Collection<? extends T> batchToSave, String collectionName)
ReactiveMongoOperationsinsert in interface ReactiveMongoOperationsbatchToSave - the list of objects to save.collectionName - name of the collection to store the object inpublic <T> reactor.core.publisher.Flux<T> insertAll(Collection<? extends T> objectsToSave)
ReactiveMongoOperationsinsertAll in interface ReactiveMongoOperationsobjectsToSave - the list of objects to save.public <T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> objectsToSave)
ReactiveMongoOperationsinsertAll in interface ReactiveMongoOperationsobjectsToSave - the publisher which provides objects to save.protected <T> reactor.core.publisher.Flux<T> doInsertAll(Collection<? extends T> listToSave, MongoWriter<Object> writer)
protected <T> reactor.core.publisher.Flux<T> doInsertBatch(String collectionName, Collection<? extends T> batchToSave, MongoWriter<Object> writer)
public <T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> objectToSave)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
Spring's Type Conversion" for more details.save in interface ReactiveMongoOperationsobjectToSave - the object to store in the collectionpublic <T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> objectToSave,
String collectionName)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See Spring's
Type Conversion" for more details.save in interface ReactiveMongoOperationsobjectToSave - the object to store in the collectioncollectionName - name of the collection to store the object inpublic <T> reactor.core.publisher.Mono<T> save(T objectToSave)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
Spring's Type Conversion" for more details.save in interface ReactiveMongoOperationsobjectToSave - the object to store in the collectionpublic <T> reactor.core.publisher.Mono<T> save(T objectToSave,
String collectionName)
ReactiveMongoOperationsMongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If you object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See Spring's
Type Conversion" for more details.save in interface ReactiveMongoOperationsobjectToSave - the object to store in the collectioncollectionName - name of the collection to store the object inprotected <T> reactor.core.publisher.Mono<T> doSave(String collectionName, T objectToSave, MongoWriter<Object> writer)
protected reactor.core.publisher.Mono<Object> insertDBObject(String collectionName, org.bson.Document dbDoc, Class<?> entityClass)
protected reactor.core.publisher.Flux<org.bson.types.ObjectId> insertDocumentList(String collectionName, List<org.bson.Document> dbDocList)
protected reactor.core.publisher.Mono<Object> saveDocument(String collectionName, org.bson.Document document, Class<?> entityClass)
public reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, Class<?> entityClass)
ReactiveMongoOperationsupsert in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be upsertedupdate - the update document that contains the updated object or $ operators to manipulate the existing objectentityClass - class that determines the collection to usepublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.upsert(Query, Update, Class, String) to get full type specific support.upsert in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.collectionName - name of the collection to update the object inpublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsupsert in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be upsertedupdate - the update document that contains the updated object or $ operators to manipulate the existing objectentityClass - class of the pojo to be operated oncollectionName - name of the collection to update the object inpublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, Class<?> entityClass)
ReactiveMongoOperationsupdateFirst in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.entityClass - class that determines the collection to usepublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.updateFirst(Query, Update, Class, String) to get full type specific support.updateFirst in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.collectionName - name of the collection to update the object inpublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.updateFirst(Query, Update, Class, String) to get full type specific support.updateFirst in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.entityClass - class of the pojo to be operated oncollectionName - name of the collection to update the object inpublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, Class<?> entityClass)
ReactiveMongoOperationsupdateMulti in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.entityClass - class that determines the collection to usepublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.updateMulti(Query, Update, Class, String) to get full type specific support.updateMulti in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.collectionName - name of the collection to update the object inpublic reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsupdateMulti in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updatedupdate - the update document that contains the updated object or $ operators to manipulate the existing
object.entityClass - class of the pojo to be operated oncollectionName - name of the collection to update the object inprotected reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> doUpdate(String collectionName, Query query, Update update, Class<?> entityClass, boolean upsert, boolean multi)
public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(reactor.core.publisher.Mono<? extends Object> objectToRemove)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationspublic reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(reactor.core.publisher.Mono<? extends Object> objectToRemove, String collection)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationscollection - must not be null or empty.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationspublic reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object, String collection)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationscollection - must not be null or empty.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.remove(Query, Class, String) to get full type specific support.remove in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to remove a recordcollectionName - name of the collection where the objects will removedpublic reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, Class<?> entityClass)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationspublic reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsprotected <T> reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> doRemove(String collectionName, Query query, Class<T> entityClass)
public <T> reactor.core.publisher.Flux<T> findAll(Class<T> entityClass)
ReactiveMongoOperationsFlux of objects of type T from the collection used by the entity class.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
to map objects since the test for class type is done in the client and not on the server.findAll in interface ReactiveMongoOperationsentityClass - the parametrized type of the returned Flux.public <T> reactor.core.publisher.Flux<T> findAll(Class<T> entityClass, String collectionName)
ReactiveMongoOperationsFlux of objects of type T from the specified collection.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way
to map objects since the test for class type is done in the client and not on the server.findAll in interface ReactiveMongoOperationsentityClass - the parametrized type of the returned Flux.collectionName - name of the collection to retrieve the objects frompublic <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, String collectionName)
ReactiveMongoOperationsReactiveMongoOperations.findAllAndRemove(Query, Class, String) to get full type specific support.findAllAndRemove in interface ReactiveMongoOperationspublic <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass)
ReactiveMongoOperationsfindAllAndRemove in interface ReactiveMongoOperationspublic <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsfindAllAndRemove in interface ReactiveMongoOperationspublic <T> reactor.core.publisher.Flux<T> tail(Query query, Class<T> entityClass)
ReactiveMongoOperationstailable cursor that may be an infinite
stream. The stream will not be completed unless the Subscription is
canceled.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.tail in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Flux.Flux of converted objectspublic <T> reactor.core.publisher.Flux<T> tail(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationstailable cursor that may be an infinite
stream. The stream will not be completed unless the Subscription is
canceled.
The object is converted from the MongoDB native representation using an instance of MongoConverter. Unless
configured otherwise, an instance of MappingMongoConverter will be used.
The query is specified as a Query which can be created either using the BasicQuery or the more
feature rich Query.tail in interface ReactiveMongoOperationsquery - the query class that specifies the criteria used to find a record and also an optional fields
specificationentityClass - the parametrized type of the returned Flux.collectionName - name of the collection to retrieve the objects fromFlux of converted objectspublic <T> ReactiveFindOperation.ReactiveFind<T> query(Class<T> domainType)
ReactiveFindOperationquery in interface ReactiveFindOperationdomainType - must not be null.ReactiveFindOperation.ReactiveFind. Never null.public <T> ReactiveUpdateOperation.ReactiveUpdate<T> update(Class<T> domainType)
ReactiveUpdateOperationupdate in interface ReactiveUpdateOperationdomainType - must not be null.ReactiveUpdateOperation.ReactiveUpdate. Never null.public <T> ReactiveRemoveOperation.ReactiveRemove<T> remove(Class<T> domainType)
ReactiveRemoveOperationremove in interface ReactiveRemoveOperationdomainType - must not be null.ReactiveRemoveOperation.ReactiveRemove. Never null.public <T> ReactiveInsertOperation.ReactiveInsert<T> insert(Class<T> domainType)
ReactiveInsertOperationinsert in interface ReactiveInsertOperationdomainType - must not be null.ReactiveInsertOperation.ReactiveInsert. Never null.public <T> ReactiveAggregationOperation.ReactiveAggregation<T> aggregateAndReturn(Class<T> domainType)
ReactiveAggregationOperationTypedAggregation to specify a potentially different
input type for he aggregation.aggregateAndReturn in interface ReactiveAggregationOperationdomainType - must not be null.ReactiveAggregationOperation.ReactiveAggregation. Never null.protected <T> reactor.core.publisher.Flux<T> doFindAndDelete(String collectionName, Query query, Class<T> entityClass)
query by calling find(Query, Class, String)
and remove(Query, Class, String), whereas the Query for remove(Query, Class, String) is
constructed out of the find result.collectionName - query - entityClass - protected reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> doCreateCollection(String collectionName, com.mongodb.client.model.CreateCollectionOptions collectionOptions)
collectionName - collectionOptions - protected <T> reactor.core.publisher.Mono<T> doFindOne(String collectionName, org.bson.Document query, org.bson.Document fields, Class<T> entityClass, Collation collation)
Document and so is the fields specification.collectionName - name of the collection to retrieve the objects from.query - the query document that specifies the criteria used to find a record.fields - the document that specifies the fields to be returned.entityClass - the parameterized type of the returned list.List of converted objects.protected <T> reactor.core.publisher.Flux<T> doFind(String collectionName, org.bson.Document query, org.bson.Document fields, Class<T> entityClass)
collectionName - name of the collection to retrieve the objects fromquery - the query document that specifies the criteria used to find a recordfields - the document that specifies the fields to be returnedentityClass - the parameterized type of the returned list.protected <T> reactor.core.publisher.Flux<T> doFind(String collectionName, org.bson.Document query, org.bson.Document fields, Class<T> entityClass, org.springframework.data.mongodb.core.FindPublisherPreparer preparer)
MongoConverter. The query document is
specified as a standard Document and so is the fields specification.collectionName - name of the collection to retrieve the objects from.query - the query document that specifies the criteria used to find a record.fields - the document that specifies the fields to be returned.entityClass - the parameterized type of the returned list.preparer - allows for customization of the DBCursor used when iterating over the result set, (apply
limits, skips and so on).List of converted objects.protected <S,T> reactor.core.publisher.Flux<T> doFind(String collectionName, org.bson.Document query, org.bson.Document fields, Class<S> entityClass, org.springframework.data.mongodb.core.FindPublisherPreparer preparer, org.springframework.data.mongodb.core.ReactiveMongoTemplate.DocumentCallback<T> objectCallback)
protected com.mongodb.client.model.CreateCollectionOptions convertToCreateCollectionOptions(CollectionOptions collectionOptions)
protected <T> reactor.core.publisher.Mono<T> doFindAndRemove(String collectionName, org.bson.Document query, org.bson.Document fields, org.bson.Document sort, Collation collation, Class<T> entityClass)
collectionName - name of the collection to retrieve the objects fromquery - the query document that specifies the criteria used to find a recordcollation - collationentityClass - the parameterized type of the returned list.protected <T> reactor.core.publisher.Mono<T> doFindAndModify(String collectionName, org.bson.Document query, org.bson.Document fields, org.bson.Document sort, Class<T> entityClass, Update update, FindAndModifyOptions options)
protected <T> void maybeEmitEvent(MongoMappingEvent<T> event)
protected void ensureNotIterable(Object o)
protected com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> prepareCollection(com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> collection)
collection - protected com.mongodb.WriteConcern prepareWriteConcern(MongoAction mongoAction)
WriteConcern will be defaulted to WriteConcern.ACKNOWLEDGED when
WriteResultChecking is set to WriteResultChecking.EXCEPTION.mongoAction - any WriteConcern already configured or nullsetWriteConcern(WriteConcern),
setWriteConcernResolver(WriteConcernResolver)Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.