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.DistinctWithProjection, ReactiveFindOperation.DistinctWithQuery<T>, ReactiveFindOperation.FindDistinct, ReactiveFindOperation.FindWithCollection<T>, ReactiveFindOperation.FindWithProjection<T>, ReactiveFindOperation.FindWithQuery<T>, ReactiveFindOperation.ReactiveFind<T>, ReactiveFindOperation.TerminatingDistinct<T>, ReactiveFindOperation.TerminatingFind<T>, ReactiveFindOperation.TerminatingFindNear<T>ReactiveInsertOperation.InsertWithCollection<T>, ReactiveInsertOperation.ReactiveInsert<T>, ReactiveInsertOperation.TerminatingInsert<T>ReactiveUpdateOperation.FindAndModifyWithOptions<T>, ReactiveUpdateOperation.FindAndReplaceWithOptions<T>, ReactiveUpdateOperation.FindAndReplaceWithProjection<T>, ReactiveUpdateOperation.ReactiveUpdate<T>, ReactiveUpdateOperation.TerminatingFindAndModify<T>, ReactiveUpdateOperation.TerminatingFindAndReplace<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>ReactiveMapReduceOperation.MapReduceWithCollection<T>, ReactiveMapReduceOperation.MapReduceWithMapFunction<T>, ReactiveMapReduceOperation.MapReduceWithOptions<T>, ReactiveMapReduceOperation.MapReduceWithProjection<T>, ReactiveMapReduceOperation.MapReduceWithQuery<T>, ReactiveMapReduceOperation.MapReduceWithReduceFunction<T>, ReactiveMapReduceOperation.ReactiveMapReduce<T>, ReactiveMapReduceOperation.TerminatingMapReduce<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.
|
ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory,
MongoConverter mongoConverter,
Consumer<Throwable> subscriptionExceptionHandler)
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.Flux<ChangeStreamEvent<T>> |
changeStream(String database,
String collectionName,
ChangeStreamOptions options,
Class<T> targetType)
Subscribe to a MongoDB Change Stream via the reactive
infrastructure.
|
<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) |
protected com.mongodb.client.model.CreateCollectionOptions |
convertToCreateCollectionOptions(CollectionOptions collectionOptions,
Class<?> entityType) |
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> |
doFindAndReplace(String collectionName,
org.bson.Document mappedQuery,
org.bson.Document mappedFields,
org.bson.Document mappedSort,
com.mongodb.client.model.Collation collation,
Class<?> entityType,
org.bson.Document replacement,
FindAndReplaceOptions options,
Class<T> resultType)
Customize this part for findAndReplace.
|
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 com.mongodb.reactivestreams.client.MongoDatabase |
doGetDatabase() |
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.
|
<S,T> reactor.core.publisher.Mono<T> |
findAndReplace(Query query,
S replacement,
FindAndReplaceOptions options,
Class<S> entityType,
String collectionName,
Class<T> resultType)
Triggers
findOneAndReplace
to replace a single document matching
Criteria of given Query with the replacement document
taking FindAndReplaceOptions into account. |
<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.Flux<T> |
findDistinct(Query query,
String field,
Class<?> entityClass,
Class<T> resultClass)
Finds the distinct values for a specified field across a single
MongoCollection or view and
returns the results in a Flux. |
<T> reactor.core.publisher.Flux<T> |
findDistinct(Query query,
String field,
String collectionName,
Class<?> entityClass,
Class<T> resultClass)
Finds the distinct values for a specified field across a single
MongoCollection or view and
returns the results in a Flux. |
<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
MongoCollection by name. |
String |
getCollectionName(Class<?> entityClass)
The collection name used for the specified class by this template.
|
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> |
insertDocument(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) |
ReactiveSessionScoped |
inTransaction()
|
ReactiveSessionScoped |
inTransaction(org.reactivestreams.Publisher<com.mongodb.reactivestreams.client.ClientSession> sessionProvider)
Obtain a
session bound instance of ReactiveSessionScoped, start the transaction and
bind the ClientSession provided by the given Publisher to each and every command issued against
MongoDB. |
<T> ReactiveMapReduceOperation.ReactiveMapReduce<T> |
mapReduce(Class<T> domainType)
Start creating a mapReduce operation for the given domainType.
|
<T> reactor.core.publisher.Flux<T> |
mapReduce(Query filterQuery,
Class<?> domainType,
Class<T> resultType,
String mapFunction,
String reduceFunction,
MapReduceOptions options)
Execute a map-reduce operation.
|
<T> reactor.core.publisher.Flux<T> |
mapReduce(Query filterQuery,
Class<?> domainType,
String inputCollectionName,
Class<T> resultType,
String mapFunction,
String reduceFunction,
MapReduceOptions options)
Execute a map-reduce operation.
|
protected <E extends MongoMappingEvent<T>,T> |
maybeEmitEvent(E 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.reactivestreams.client.MongoDatabase |
prepareDatabase(com.mongodb.reactivestreams.client.MongoDatabase database) |
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 collectionName)
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 collectionName)
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 {@link 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.
|
ReactiveMongoOperations |
withSession(com.mongodb.reactivestreams.client.ClientSession session)
Obtain a
ClientSession bound instance of ReactiveMongoOperations. |
ReactiveSessionScoped |
withSession(com.mongodb.ClientSessionOptions sessionOptions)
Obtain a
session bound instance of SessionScoped binding a new ClientSession
with given sessionOptions to each and every command issued against MongoDB. |
ReactiveSessionScoped |
withSession(org.reactivestreams.Publisher<com.mongodb.reactivestreams.client.ClientSession> sessionProvider)
Obtain a
session bound instance of ReactiveSessionScoped binding the
ClientSession provided by the given Publisher to each and every command issued against MongoDB. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchangeStream, changeStream, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findAndReplace, findDistinct, findDistinct, withSessionpublic 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, @Nullable MongoConverter mongoConverter)
mongoDatabaseFactory - must not be null.mongoConverter - can be null.public ReactiveMongoTemplate(ReactiveMongoDatabaseFactory mongoDatabaseFactory, @Nullable MongoConverter mongoConverter, Consumer<Throwable> subscriptionExceptionHandler)
mongoDatabaseFactory - must not be null.mongoConverter - can be null.subscriptionExceptionHandler - exception handler called by Flux.doOnError(Consumer) on reactive type
materialization via Publisher.subscribe(Subscriber). This callback is used during non-blocking
subscription of e.g. index creation Publishers. Must not be null.public void setWriteResultChecking(@Nullable WriteResultChecking resultChecking)
WriteResultChecking to be used with the template. Setting null will reset the
default of DEFAULT_WRITE_RESULT_CHECKING.resultChecking - public void setWriteConcern(@Nullable 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 - can be null.public void setWriteConcernResolver(@Nullable WriteConcernResolver writeConcernResolver)
WriteConcernResolver to be used with the template.writeConcernResolver - can be null.public void setReadPreference(com.mongodb.ReadPreference readPreference)
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 ReactiveMongoOperationscollectionName - must not be null.public ReactiveIndexOperations indexOps(Class<?> entityClass)
ReactiveMongoOperationsindexOps in interface ReactiveMongoOperationsentityClass - must not be null.public String getCollectionName(Class<?> entityClass)
ReactiveMongoOperationsgetCollectionName in interface ReactiveMongoOperationsentityClass - must not be null.public 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 command.public reactor.core.publisher.Mono<org.bson.Document> executeCommand(org.bson.Document command,
@Nullable
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 type.entityClass - class that determines the collection to use. Must not be null.action - callback object that specifies the MongoDB action. Must not be null.public <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 type.action - callback object that specifies the MongoDB actions to perform on the passed in DB instance. Must not
be null.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 type.collectionName - the name of the collection that specifies which MongoCollection instance will be
passed into. Must not be null or empty.callback - callback object that specifies the MongoDB action the callback action. Must not be null.public ReactiveSessionScoped withSession(org.reactivestreams.Publisher<com.mongodb.reactivestreams.client.ClientSession> sessionProvider)
ReactiveMongoOperationssession bound instance of ReactiveSessionScoped binding the
ClientSession provided by the given Publisher to each and every command issued against MongoDB.
Note: It is up to the caller to manage the ClientSession lifecycle. Use
ReactiveSessionScoped.execute(ReactiveSessionCallback, Consumer) to provide a hook for processing the
ClientSession when done.withSession in interface ReactiveMongoOperationssessionProvider - must not be null.ReactiveSessionScoped. Never null.public ReactiveSessionScoped inTransaction()
ReactiveMongoOperationsClientSession and obtain a session bound instance of
ReactiveSessionScoped. Starts the transaction and adds the ClientSession to each and every command
issued against MongoDB.
Each execution initiates a new managed transaction
that is committed on success. Transactions are
rolled back upon errors.inTransaction in interface ReactiveMongoOperationsReactiveSessionScoped. Never null.public ReactiveSessionScoped inTransaction(org.reactivestreams.Publisher<com.mongodb.reactivestreams.client.ClientSession> sessionProvider)
ReactiveMongoOperationssession bound instance of ReactiveSessionScoped, start the transaction and
bind the ClientSession provided by the given Publisher to each and every command issued against
MongoDB.
Each execution initiates a new managed transaction
that is committed on success. Transactions are
rolled back upon errors.inTransaction in interface ReactiveMongoOperationssessionProvider - must not be null.ReactiveSessionScoped. Never null.public ReactiveMongoOperations withSession(com.mongodb.reactivestreams.client.ClientSession session)
ReactiveMongoOperationsClientSession bound instance of ReactiveMongoOperations.
Note: It is up to the caller to manage the ClientSession lifecycle.withSession in interface ReactiveMongoOperationssession - must not be null.ClientSession bound instance of ReactiveMongoOperations.public ReactiveSessionScoped withSession(com.mongodb.ClientSessionOptions sessionOptions)
ReactiveMongoOperationssession bound instance of SessionScoped binding a new ClientSession
with given sessionOptions to each and every command issued against MongoDB.
Note: It is up to the caller to manage the ClientSession lifecycle. Use
ReactiveSessionScoped.execute(ReactiveSessionCallback, Consumer) to provide a hook for processing the
ClientSession when done.withSession in interface ReactiveMongoOperationssessionOptions - must not be null.ReactiveSessionScoped. Never null.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 create.public <T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(Class<T> entityClass, @Nullable CollectionOptions collectionOptions)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationsentityClass - class that determines the collection to create. Must not be null.collectionOptions - 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 collection.public reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(String collectionName, @Nullable CollectionOptions collectionOptions)
ReactiveMongoOperationscreateCollection in interface ReactiveMongoOperationscollectionName - name of the collection. Must not be null nor empty.collectionOptions - options to use when creating the collection.public com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> getCollection(String collectionName)
ReactiveMongoOperationsMongoCollection by name. The returned collection may not exists yet (except in local memory) and is
created on first interaction with the server. Collections can be explicitly created via
ReactiveMongoOperations.createCollection(Class). Please make sure to check if the collection exists first.
Translate any exceptions as necessary.getCollection in interface ReactiveMongoOperationscollectionName - name of the collection.public <T> reactor.core.publisher.Mono<Boolean> collectionExists(Class<T> entityClass)
ReactiveMongoOperationscollectionExists in interface ReactiveMongoOperationsentityClass - class that determines the name of the collection. Must not be null.public reactor.core.publisher.Mono<Boolean> collectionExists(String collectionName)
ReactiveMongoOperationscollectionExists in interface ReactiveMongoOperationscollectionName - name of the collection. Must not be null.public <T> reactor.core.publisher.Mono<Void> dropCollection(Class<T> entityClass)
ReactiveMongoOperationsdropCollection in interface ReactiveMongoOperationsentityClass - class that determines the collection to drop/delete. Must not be null.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()
protected com.mongodb.reactivestreams.client.MongoDatabase doGetDatabase()
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
specification.entityClass - 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
specification.entityClass - the parametrized type of the returned Mono.collectionName - name of the collection to retrieve the objects from.public 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, @Nullable 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. Can be null.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
specification. Must not be null.entityClass - the parametrized type of the returned Flux. Must not be null.Flux of converted objects.public <T> reactor.core.publisher.Flux<T> find(@Nullable 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
specification. Must not be null.entityClass - the parametrized type of the returned Flux.collectionName - name of the collection to retrieve the objects from. Must not be null.Flux of converted objects.public <T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> entityClass)
ReactiveMongoOperationsfindById in interface ReactiveMongoOperationsid - the id of the document to return. Must not be null.entityClass - the type the document shall be converted into. Must not be null.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 return.entityClass - the type to convert the document to.collectionName - the collection to query for the document.public <T> reactor.core.publisher.Flux<T> findDistinct(Query query, String field, Class<?> entityClass, Class<T> resultClass)
ReactiveMongoOperationsMongoCollection or view and
returns the results in a Flux.findDistinct in interface ReactiveMongoOperationsquery - filter Query to restrict search. Must not be null.field - the name of the field to inspect for distinct values. Must not be null.entityClass - the domain type used for determining the actual MongoCollection and mapping the
Query to the domain type fields. Must not be null.resultClass - the result type. Must not be null.public <T> reactor.core.publisher.Flux<T> findDistinct(Query query, String field, String collectionName, Class<?> entityClass, Class<T> resultClass)
ReactiveMongoOperationsMongoCollection or view and
returns the results in a Flux.findDistinct in interface ReactiveMongoOperationsquery - filter Query to restrict search. Must not be null.field - the name of the field to inspect for distinct values. Must not be null.collectionName - the explicit name of the actual MongoCollection. Must not be null.entityClass - the domain type used for mapping the Query to the domain type fields.resultClass - the result type. Must not be null.public <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, @Nullable 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.GeoResults.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.GeoResults.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. Must not be null.update - the Update to apply on matching documents. Must not be null.entityClass - the parametrized type. Must not be null.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. Must not be null.update - the Update to apply on matching documents. Must not be null.entityClass - the parametrized type. Must not be null.collectionName - the collection to query. Must not be null.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.FindAndModifyOptions.isReturnNew()
this will either be the object as it was before the update or as it is after the update.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. Must not be null.update - the Update to apply on matching documents. Must not be null.options - the FindAndModifyOptions holding additional information. Must not be null.entityClass - the parametrized type. Must not be null.collectionName - the collection to query. Must not be null.FindAndModifyOptions.isReturnNew()
this will either be the object as it was before the update or as it is after the update.public <S,T> reactor.core.publisher.Mono<T> findAndReplace(Query query, S replacement, FindAndReplaceOptions options, Class<S> entityType, String collectionName, Class<T> resultType)
ReactiveMongoOperationsCriteria of given Query with the replacement document
taking FindAndReplaceOptions into account. findAndReplace in interface ReactiveMongoOperationsquery - the Query class that specifies the Criteria used to find a record and also an optional
fields specification. Must not be null.replacement - the replacement document. Must not be null.options - the FindAndModifyOptions holding additional information. Must not be null.entityType - the type used for mapping the Query to domain type fields and deriving the collection
from. Must not be null.collectionName - the collection to query. Must not be null.resultType - resultType the parametrized type projection return type. Must not be null, use the
domain type of Object.class instead.Mono.empty(), if not found. Depending on the value of
FindAndReplaceOptions.isReturnNew() this will either be the object as it was before the update or
as it is after the update.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
specification.entityClass - 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
specification.entityClass - 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 ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find documents. Must not be
null.entityClass - class that determines the collection to use. 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 ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find documents.collectionName - must not be null or empty.ReactiveMongoOperations.count(Query, Class, String)public reactor.core.publisher.Mono<Long> count(Query query, @Nullable Class<?> entityClass, String collectionName)
ReactiveMongoOperationsQuery by querying the given collection using the given entity
class to map the given Query.count in interface ReactiveMongoOperationsquery - the Query class that specifies the criteria used to find documents. Must not be
null.entityClass - the parametrized type. Can 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. Must not be null.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. Must not be null.entityClass - class that determines the collection to use. Must not be null.public <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. Must not be null.collectionName - name of the collection to store the object in. Must not be null.public <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. Must not be null.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 collection. Must not be null.collectionName - name of the collection to store the object in. Must not be null.protected <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. Must not be null.entityClass - class that determines the collection to use. Must not be null.public <T> reactor.core.publisher.Flux<T> insert(Collection<? extends T> batchToSave, String collectionName)
ReactiveMongoOperationsinsert in interface ReactiveMongoOperationsbatchToSave - the list of objects to save. Must not be null.collectionName - name of the collection to store the object in. Must not be null.public <T> reactor.core.publisher.Flux<T> insertAll(Collection<? extends T> objectsToSave)
ReactiveMongoOperationsinsertAll in interface ReactiveMongoOperationsobjectsToSave - the list of objects to save. Must not be null.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. Must not be null.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 collection. Must not be null.public <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 collection. Must not be null.collectionName - name of the collection to store the object in. Must not be null.public <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 collection. Must not be null.public <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 collection. Must not be null.collectionName - name of the collection to store the object in. Must not be null.protected <T> reactor.core.publisher.Mono<T> doSave(String collectionName, T objectToSave, MongoWriter<Object> writer)
protected reactor.core.publisher.Mono<Object> insertDocument(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 upserted. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing
object. Must not be null.entityClass - class that determines the collection to use. Must not be null.UpdateResult which lets you access the results of the previous write.public 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 upserted. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing
object. Must not be null.collectionName - name of the collection to update the object in.UpdateResult which lets you access the results of the previous write.public 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 upserted. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing
object. Must not be null.entityClass - class of the pojo to be operated on. Must not be null.collectionName - name of the collection to update the object in. Must not be null.UpdateResult which lets you access the results of the previous write.public 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 updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.entityClass - class that determines the collection to use.UpdateResult which lets you access the results of the previous write.public 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 updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.collectionName - name of the collection to update the object in. Must not be null.UpdateResult which lets you access the results of the previous write.public reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, Class<?> entityClass, String collectionName)
ReactiveMongoOperationsupdateFirst in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to select a record to be updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.entityClass - class of the pojo to be operated on. Must not be null.collectionName - name of the collection to update the object in. Must not be null.UpdateResult which lets you access the results of the previous write.public 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 updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.entityClass - class of the pojo to be operated on. Must not be null.UpdateResult which lets you access the results of the previous write.public 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 updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.collectionName - name of the collection to update the object in. Must not be null.UpdateResult which lets you access the results of the previous write.public 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 updated. Must not be
null.update - the update document that contains the updated object or $ operators to manipulate the existing. Must
not be null.entityClass - class of the pojo to be operated on. Must not be null.collectionName - name of the collection to update the object in. Must not be null.UpdateResult which lets you access the results of the previous write.protected reactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> doUpdate(String collectionName, Query query, @Nullable Update update, @Nullable 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 ReactiveMongoOperationsobjectToRemove - must not be null.DeleteResult which lets you access the results of the previous delete.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(reactor.core.publisher.Mono<? extends Object> objectToRemove, String collectionName)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsobjectToRemove - must not be null.collectionName - name of the collection where the objects will removed, must not be null or empty.DeleteResult which lets you access the results of the previous delete.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsobject - must not be null.DeleteResult which lets you access the results of the previous delete.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object, String collectionName)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsobject - must not be null.collectionName - name of the collection where the objects will removed, must not be null or empty.DeleteResult which lets you access the results of the previous delete.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 record.collectionName - name of the collection where the objects will removed, must not be null or empty.DeleteResult which lets you access the results of the previous delete.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, Class<?> entityClass)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to remove a record.entityClass - class that determines the collection to use.DeleteResult which lets you access the results of the previous delete.public reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, @Nullable Class<?> entityClass, String collectionName)
ReactiveMongoOperationsremove in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to remove a record.entityClass - class of the pojo to be operated on. Can be null.collectionName - name of the collection where the objects will removed, must not be null or empty.DeleteResult which lets you access the results of the previous delete.protected <T> reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> doRemove(String collectionName, Query query, @Nullable 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 from.public <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 ReactiveMongoOperationsquery - the query document that specifies the criteria used to find and remove documents.collectionName - name of the collection where the objects will removed, must not be null or empty.Flux converted objects deleted by this operation.public <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass)
ReactiveMongoOperationsfindAllAndRemove in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to find and remove documents.entityClass - class of the pojo to be operated on.Flux converted objects deleted by this operation.public <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass, String collectionName)
ReactiveMongoOperationsfindAllAndRemove in interface ReactiveMongoOperationsquery - the query document that specifies the criteria used to find and remove documents.entityClass - class of the pojo to be operated on.collectionName - name of the collection where the objects will removed, must not be null or empty.Flux converted objects deleted by this operation.public <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
specification.entityClass - the parametrized type of the returned Flux.Flux of converted objects.public <T> reactor.core.publisher.Flux<T> tail(@Nullable 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
specification.entityClass - the parametrized type of the returned Flux.collectionName - name of the collection to retrieve the objects from.Flux of converted objects.public <T> reactor.core.publisher.Flux<ChangeStreamEvent<T>> changeStream(@Nullable String database, @Nullable String collectionName, ChangeStreamOptions options, Class<T> targetType)
ReactiveMongoOperationsAggregation to filter events. The stream will not be completed
unless the Subscription is canceled.
The ChangeStreamEvent.getBody() is mapped to the resultType while the
ChangeStreamEvent.getRaw() contains the unmodified payload.
Use ChangeStreamOptions to set arguments like the resumseToken
for resuming change streams.changeStream in interface ReactiveMongoOperationsdatabase - the database to watch. Can be null, uses configured default if so.collectionName - the collection to watch. Can be null, watches all collections if so.options - must not be null. Use ChangeStreamOptions.empty().targetType - the result type to use.Flux emitting events as they arrive.ChangeStreamOptions.getFilter()public <T> reactor.core.publisher.Flux<T> mapReduce(Query filterQuery, Class<?> domainType, Class<T> resultType, String mapFunction, String reduceFunction, MapReduceOptions options)
ReactiveMongoOperationsMapReduceOptions to optionally specify an output collection and other
args.mapReduce in interface ReactiveMongoOperationsfilterQuery - the selection criteria for the documents going input to the map function. Must not be
null.domainType - source type used to determine the input collection name and map the filter Query against.
Must not be null.resultType - the mapping target of the operations result documents. Must not be null.mapFunction - the JavaScript map function. Must not be null.reduceFunction - the JavaScript reduce function. Must not be null.options - additional options like output collection. Must not be null.Flux emitting the result document sequence. Never null.public <T> reactor.core.publisher.Flux<T> mapReduce(Query filterQuery, Class<?> domainType, String inputCollectionName, Class<T> resultType, String mapFunction, String reduceFunction, MapReduceOptions options)
ReactiveMongoOperationsMapReduceOptions to optionally specify an output collection and other
args.mapReduce in interface ReactiveMongoOperationsfilterQuery - the selection criteria for the documents going input to the map function. Must not be
null.domainType - source type used to map the filter Query against. Must not be null.inputCollectionName - the input collection.resultType - the mapping target of the operations result documents. Must not be null.mapFunction - the JavaScript map function. Must not be null.reduceFunction - the JavaScript reduce function. Must not be null.options - additional options like output collection. Must not be null.Flux emitting the result document sequence. Never null.public <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.public <T> ReactiveMapReduceOperation.ReactiveMapReduce<T> mapReduce(Class<T> domainType)
ReactiveMapReduceOperationmapReduce in interface ReactiveMapReduceOperationdomainType - must not be null.ExecutableFindOperation.ExecutableFind.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, @Nullable org.bson.Document fields, Class<T> entityClass, @Nullable 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.collation - can be null.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, @Nullable org.springframework.data.mongodb.core.FindPublisherPreparer preparer, org.springframework.data.mongodb.core.ReactiveMongoTemplate.DocumentCallback<T> objectCallback)
protected com.mongodb.client.model.CreateCollectionOptions convertToCreateCollectionOptions(@Nullable CollectionOptions collectionOptions)
protected com.mongodb.client.model.CreateCollectionOptions convertToCreateCollectionOptions(@Nullable CollectionOptions collectionOptions, Class<?> entityType)
protected <T> reactor.core.publisher.Mono<T> doFindAndRemove(String collectionName, org.bson.Document query, org.bson.Document fields, org.bson.Document sort, @Nullable 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> reactor.core.publisher.Mono<T> doFindAndReplace(String collectionName, org.bson.Document mappedQuery, org.bson.Document mappedFields, org.bson.Document mappedSort, com.mongodb.client.model.Collation collation, Class<?> entityType, org.bson.Document replacement, FindAndReplaceOptions options, Class<T> resultType)
collectionName - The name of the collection to perform the operation in.mappedQuery - the query to look up documents.mappedFields - the fields to project the result to.mappedSort - the sort to be applied when executing the query.collation - collation settings for the query. Can be null.entityType - the source domain type.replacement - the replacement Document.options - applicable options.resultType - the target domain type.Mono.empty() if object does not exist, return new is
false and upsert is false.protected <E extends MongoMappingEvent<T>,T> E maybeEmitEvent(E 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.reactivestreams.client.MongoDatabase prepareDatabase(com.mongodb.reactivestreams.client.MongoDatabase database)
database - @Nullable 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 null.setWriteConcern(WriteConcern),
setWriteConcernResolver(WriteConcernResolver)Copyright © 2011–2019 Pivotal Software, Inc.. All rights reserved.