public interface ReactiveMongoOperations
Implemented by ReactiveMongoTemplate
. Not often used but a useful option for extensibility and testability
(as it can be easily mocked, stubbed, or be the target of a JDK proxy). Command execution using
ReactiveMongoOperations
is deferred until subscriber subscribes to the Publisher
.
Flux
,
Mono
,
Project ReactorModifier and Type | Method and Description |
---|---|
<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.
|
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.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.
|
<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> action)
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.
|
<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.
|
reactor.core.publisher.Flux<String> |
getCollectionNames()
A set of collection names.
|
MongoConverter |
getConverter()
Returns the underlying
MongoConverter . |
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> 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.
|
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.
|
<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.
|
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.
|
ReactiveIndexOperations indexOps(String collectionName)
ReactiveIndexOperations indexOps(Class<?> entityClass)
reactor.core.publisher.Mono<org.bson.Document> executeCommand(String jsonCommand)
jsonCommand
- a MongoDB command expressed as a JSON string.reactor.core.publisher.Mono<org.bson.Document> executeCommand(org.bson.Document command)
command
- a MongoDB commandreactor.core.publisher.Mono<org.bson.Document> executeCommand(org.bson.Document command, com.mongodb.ReadPreference readPreference)
command
- a MongoDB command, must not be null.readPreference
- read preferences to use, can be null.<T> reactor.core.publisher.Flux<T> execute(ReactiveDatabaseCallback<T> action)
ReactiveDatabaseCallback
translating any exceptions as necessary.
Allows for returning a result object, that is a domain object or a collection of domain objects.T
- return typeaction
- callback object that specifies the MongoDB actions to perform on the passed in DB instance.<T> reactor.core.publisher.Flux<T> execute(Class<?> entityClass, ReactiveCollectionCallback<T> action)
ReactiveCollectionCallback
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.T
- return typeentityClass
- class that determines the collection to useaction
- callback object that specifies the MongoDB action<T> reactor.core.publisher.Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> action)
ReactiveCollectionCallback
on the collection of the given name.
Allows for returning a result object, that is a domain object or a collection of domain objects.T
- return typecollectionName
- the name of the collection that specifies which DBCollection instance will be passed intoaction
- callback object that specifies the MongoDB action the callback action.<T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(Class<T> entityClass)
entityClass
- class that determines the collection to create<T> reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(Class<T> entityClass, CollectionOptions collectionOptions)
entityClass
- class that determines the collection to createcollectionOptions
- options to use when creating the collection.reactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(String collectionName)
collectionName
- name of the collectionreactor.core.publisher.Mono<com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document>> createCollection(String collectionName, CollectionOptions collectionOptions)
collectionName
- name of the collectioncollectionOptions
- options to use when creating the collection.reactor.core.publisher.Flux<String> getCollectionNames()
com.mongodb.reactivestreams.client.MongoCollection<org.bson.Document> getCollection(String collectionName)
collectionName
- name of the collection<T> reactor.core.publisher.Mono<Boolean> collectionExists(Class<T> entityClass)
entityClass
- class that determines the name of the collectionreactor.core.publisher.Mono<Boolean> collectionExists(String collectionName)
collectionName
- name of the collection<T> reactor.core.publisher.Mono<Void> dropCollection(Class<T> entityClass)
entityClass
- class that determines the collection to drop/delete.reactor.core.publisher.Mono<Void> dropCollection(String collectionName)
collectionName
- name of the collection to drop/delete.<T> reactor.core.publisher.Flux<T> findAll(Class<T> entityClass)
Flux
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.entityClass
- the parametrized type of the returned Flux
.<T> reactor.core.publisher.Flux<T> findAll(Class<T> entityClass, String collectionName)
Flux
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.entityClass
- the parametrized type of the returned Flux
.collectionName
- name of the collection to retrieve the objects from<T> reactor.core.publisher.Mono<T> findOne(Query query, Class<T> entityClass)
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
.query
- 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
.<T> reactor.core.publisher.Mono<T> findOne(Query query, Class<T> entityClass, String collectionName)
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
.query
- 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 fromreactor.core.publisher.Mono<Boolean> exists(Query query, String collectionName)
Query
contains at least one element.query
- the Query
class that specifies the criteria used to find a record.collectionName
- name of the collection to check for objects.reactor.core.publisher.Mono<Boolean> exists(Query query, Class<?> entityClass)
Query
contains at least one element.query
- the Query
class that specifies the criteria used to find a record.entityClass
- the parametrized type.reactor.core.publisher.Mono<Boolean> exists(Query query, Class<?> entityClass, String collectionName)
Query
contains at least one element.query
- 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.<T> reactor.core.publisher.Flux<T> find(Query query, Class<T> entityClass)
Flux
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
.query
- 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 objects<T> reactor.core.publisher.Flux<T> find(Query query, Class<T> entityClass, String collectionName)
Flux
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
.query
- 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 objects<T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> entityClass)
T
- id
- the id of the document to return.entityClass
- the type the document shall be converted into.<T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> entityClass, String collectionName)
T
- id
- the id of the document to returnentityClass
- the type to convert the document tocollectionName
- the collection to query for the document<T> reactor.core.publisher.Flux<GeoResult<T>> geoNear(NearQuery near, Class<T> entityClass)
Flux
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.near
- must not be null.entityClass
- must not be null.<T> reactor.core.publisher.Flux<GeoResult<T>> geoNear(NearQuery near, Class<T> entityClass, String collectionName)
Flux
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.near
- 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.<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)
Update
on documents matching Criteria
of given Query
taking
FindAndModifyOptions
into account.query
- 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.<T> reactor.core.publisher.Mono<T> findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass, String collectionName)
Update
on documents matching Criteria
of given Query
taking
FindAndModifyOptions
into account.query
- 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.<T> reactor.core.publisher.Mono<T> findAndRemove(Query query, Class<T> entityClass)
MongoConverter
.
The query is specified as a Query
which can be created either using the BasicQuery
or the more
feature rich Query
.query
- 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
.<T> reactor.core.publisher.Mono<T> findAndRemove(Query query, Class<T> entityClass, String collectionName)
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
.query
- 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.reactor.core.publisher.Mono<Long> count(Query query, Class<?> entityClass)
Query
by querying the collection of the given entity class.query
- entityClass
- must not be null.reactor.core.publisher.Mono<Long> count(Query query, String collectionName)
Query
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. TO make sure the query gets mapped, use count(Query, Class, String)
.query
- collectionName
- must not be null or empty.count(Query, Class, String)
reactor.core.publisher.Mono<Long> count(Query query, Class<?> entityClass, String collectionName)
Query
by querying the given collection using the given entity
class to map the given Query
.query
- entityClass
- must not be null.collectionName
- must not be null or empty.<T> reactor.core.publisher.Mono<T> insert(T objectToSave)
MongoConverter
.
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.objectToSave
- the object to store in the collection.<T> reactor.core.publisher.Mono<T> insert(T objectToSave, String collectionName)
MongoConverter
. 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.objectToSave
- the object to store in the collectioncollectionName
- name of the collection to store the object in<T> reactor.core.publisher.Flux<T> insert(Collection<? extends T> batchToSave, Class<?> entityClass)
batchToSave
- the batch of objects to save.entityClass
- class that determines the collection to use<T> reactor.core.publisher.Flux<T> insert(Collection<? extends T> batchToSave, String collectionName)
batchToSave
- the list of objects to save.collectionName
- name of the collection to store the object in<T> reactor.core.publisher.Flux<T> insertAll(Collection<? extends T> objectsToSave)
objectsToSave
- the list of objects to save.<T> reactor.core.publisher.Mono<T> insert(reactor.core.publisher.Mono<? extends T> objectToSave)
MongoConverter
.
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.objectToSave
- the object to store in the collection.<T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave, Class<?> entityClass)
batchToSave
- the publisher which provides objects to save.entityClass
- class that determines the collection to use<T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> batchToSave, String collectionName)
batchToSave
- the publisher which provides objects to save.collectionName
- name of the collection to store the object in<T> reactor.core.publisher.Flux<T> insertAll(reactor.core.publisher.Mono<? extends Collection<? extends T>> objectsToSave)
objectsToSave
- the publisher which provides objects to save.<T> reactor.core.publisher.Mono<T> save(T objectToSave)
MongoConverter
. 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.objectToSave
- the object to store in the collection<T> reactor.core.publisher.Mono<T> save(T objectToSave, String collectionName)
MongoConverter
. 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.objectToSave
- the object to store in the collectioncollectionName
- name of the collection to store the object in<T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> objectToSave)
MongoConverter
. 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.objectToSave
- the object to store in the collection<T> reactor.core.publisher.Mono<T> save(reactor.core.publisher.Mono<? extends T> objectToSave, String collectionName)
MongoConverter
. 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.objectToSave
- the object to store in the collectioncollectionName
- name of the collection to store the object inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, Class<?> entityClass)
query
- 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 usereactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> upsert(Query query, Update update, Class<?> entityClass, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, Class<?> entityClass)
query
- 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 usereactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateFirst(Query query, Update update, Class<?> entityClass, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, Class<?> entityClass)
query
- 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 usereactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.UpdateResult> updateMulti(Query query, Update update, Class<?> entityClass, String collectionName)
query
- 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 inreactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object)
object
- reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Object object, String collection)
object
- collection
- must not be null or empty.reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(reactor.core.publisher.Mono<? extends Object> objectToRemove)
objectToRemove
- reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(reactor.core.publisher.Mono<? extends Object> objectToRemove, String collection)
objectToRemove
- collection
- must not be null or empty.reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, Class<?> entityClass)
query
- entityClass
- reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, Class<?> entityClass, String collectionName)
query
- entityClass
- collectionName
- reactor.core.publisher.Mono<com.mongodb.client.result.DeleteResult> remove(Query query, String collectionName)
query
- the query document that specifies the criteria used to remove a recordcollectionName
- name of the collection where the objects will removed<T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, String collectionName)
query
- collectionName
- <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass)
query
- entityClass
- <T> reactor.core.publisher.Flux<T> findAllAndRemove(Query query, Class<T> entityClass, String collectionName)
query
- entityClass
- collectionName
- <T> reactor.core.publisher.Flux<T> tail(Query query, Class<T> entityClass)
tailable
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
.query
- 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 objects<T> reactor.core.publisher.Flux<T> tail(Query query, Class<T> entityClass, String collectionName)
tailable
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
.query
- 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 objectsMongoConverter getConverter()
MongoConverter
.Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.