Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2014 the original author or authors.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.springframework.data.mongodb.core;
 
 import java.util.List;
 import java.util.Set;
 
 
Interface that specifies a basic set of MongoDB operations. Implemented by MongoTemplate. 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).

Author(s):
Thomas Risberg
Mark Pollack
Oliver Gierke
Tobias Trelle
Chuong Ngo
 
 public interface MongoOperations {

The collection name used for the specified class by this template.

Parameters:
entityClass must not be null.
Returns:
 
 	String getCollectionName(Class<?> entityClass);

Execute the a MongoDB command expressed as a JSON string. This will call the method JSON.parse that is part of the MongoDB driver to convert the JSON string to a DBObject. Any errors that result from executing this command will be converted into Spring's DAO exception hierarchy.

Parameters:
jsonCommand a MongoDB command expressed as a JSON string.
 
Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO exception hierarchy.

Parameters:
command a MongoDB command
 
Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO exception hierarchy.

Parameters:
command a MongoDB command
options query options to use
 
 	CommandResult executeCommand(DBObject commandint options);

Execute a MongoDB query and iterate over the query results on a per-document basis with a DocumentCallbackHandler.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
collectionName name of the collection to retrieve the objects from
dch the handler that will extract results, one document at a time
 
 	void executeQuery(Query queryString collectionNameDocumentCallbackHandler dch);

Executes a DbCallback translating any exceptions as necessary.

Allows for returning a result object, that is a domain object or a collection of domain objects.

Parameters:
<T> return type
action callback object that specifies the MongoDB actions to perform on the passed in DB instance.
Returns:
a result object returned by the action or null
	<T> T execute(DbCallback<T> action);

Executes the given CollectionCallback 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.

Parameters:
entityClass class that determines the collection to use
<T> return type
action callback object that specifies the MongoDB action
Returns:
a result object returned by the action or null
	<T> T execute(Class<?> entityClassCollectionCallback<T> action);

Executes the given CollectionCallback on the collection of the given name.

Allows for returning a result object, that is a domain object or a collection of domain objects.

Parameters:
<T> return type
collectionName the name of the collection that specifies which DBCollection instance will be passed into
action callback object that specifies the MongoDB action the callback action.
Returns:
a result object returned by the action or null
	<T> T execute(String collectionNameCollectionCallback<T> action);

Executes the given DbCallback within the same connection to the database so as to ensure consistency in a write heavy environment where you may read the data that you wrote. See the comments on Java Driver Concurrency

Allows for returning a result object, that is a domain object or a collection of domain objects.

Parameters:
<T> return type
action callback that specified the MongoDB actions to perform on the DB instance
Returns:
a result object returned by the action or null
	<T> T executeInSession(DbCallback<T> action);

Create an uncapped collection with a name based on the provided entity class.

Parameters:
entityClass class that determines the collection to create
Returns:
the created collection
	<T> DBCollection createCollection(Class<T> entityClass);

Create a collect with a name based on the provided entity class using the options.

Parameters:
entityClass class that determines the collection to create
collectionOptions options to use when creating the collection.
Returns:
the created collection
	<T> DBCollection createCollection(Class<T> entityClassCollectionOptions collectionOptions);

Create an uncapped collection with the provided name.

Parameters:
collectionName name of the collection
Returns:
the created collection
Create a collect with the provided name and options.

Parameters:
collectionName name of the collection
collectionOptions options to use when creating the collection.
Returns:
the created collection
	DBCollection createCollection(String collectionNameCollectionOptions collectionOptions);

A set of collection names.

Returns:
list of collection names
Get a collection by name, creating it if it doesn't exist.

Translate any exceptions as necessary.

Parameters:
collectionName name of the collection
Returns:
an existing collection or a newly created one.
	DBCollection getCollection(String collectionName);

Check to see if a collection with a name indicated by the entity class exists.

Translate any exceptions as necessary.

Parameters:
entityClass class that determines the name of the collection
Returns:
true if a collection with the given name is found, false otherwise.
	<T> boolean collectionExists(Class<T> entityClass);

Check to see if a collection with a given name exists.

Translate any exceptions as necessary.

Parameters:
collectionName name of the collection
Returns:
true if a collection with the given name is found, false otherwise.
	boolean collectionExists(String collectionName);

Drop the collection with the name indicated by the entity class.

Translate any exceptions as necessary.

Parameters:
entityClass class that determines the collection to drop/delete.
	<T> void dropCollection(Class<T> entityClass);

Drop the collection with the given name.

Translate any exceptions as necessary.

Parameters:
collectionName name of the collection to drop/delete.
	void dropCollection(String collectionName);

Returns the operations that can be performed on indexes

Returns:
index operations on the named collection
	IndexOperations indexOps(String collectionName);

Returns the operations that can be performed on indexes

Returns:
index operations on the named collection associated with the given entity class
	IndexOperations indexOps(Class<?> entityClass);

Query for a list 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.

Parameters:
entityClass the parameterized type of the returned list
Returns:
the converted collection
	<T> List<T> findAll(Class<T> entityClass);

Query for a list 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.

Parameters:
entityClass the parameterized type of the returned list.
collectionName name of the collection to retrieve the objects from
Returns:
the converted collection
	<T> List<T> findAll(Class<T> entityClassString collectionName);

Execute a group operation over the entire collection. The group operation entity class should match the 'shape' of the returned object that takes int account the initial document structure as well as any finalize functions.

Parameters:
criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are considered.
inputCollectionName the collection where the group operation will read from
groupBy the conditions under which the group operation will be performed, e.g. keys, initial document, reduce function.
entityClass The parameterized type of the returned list
Returns:
The results of the group operation
	<T> GroupByResults<T> group(String inputCollectionNameGroupBy groupByClass<T> entityClass);

Execute a group operation restricting the rows to those which match the provided Criteria. The group operation entity class should match the 'shape' of the returned object that takes int account the initial document structure as well as any finalize functions.

Parameters:
criteria The criteria that restricts the row that are considered for grouping. If not specified all rows are considered.
inputCollectionName the collection where the group operation will read from
groupBy the conditions under which the group operation will be performed, e.g. keys, initial document, reduce function.
entityClass The parameterized type of the returned list
Returns:
The results of the group operation
	<T> GroupByResults<T> group(Criteria criteriaString inputCollectionNameGroupBy groupByClass<T> entityClass);

Execute an aggregation operation. The raw results will be mapped to the given entity class. The name of the inputCollection is derived from the inputType of the aggregation.

Parameters:
aggregation The org.springframework.data.mongodb.core.aggregation.TypedAggregation specification holding the aggregation operations, must not be null.
collectionName The name of the input collection to use for the aggreation.
outputType The parameterized type of the returned list, must not be null.
Returns:
The results of the aggregation operation.
Since:
1.3
	<O> AggregationResults<O> aggregate(TypedAggregation<?> aggregationString collectionNameClass<O> outputType);

Execute an aggregation operation. The raw results will be mapped to the given entity class. The name of the inputCollection is derived from the inputType of the aggregation.

Parameters:
aggregation The org.springframework.data.mongodb.core.aggregation.TypedAggregation specification holding the aggregation operations, must not be null.
outputType The parameterized type of the returned list, must not be null.
Returns:
The results of the aggregation operation.
Since:
1.3
	<O> AggregationResults<O> aggregate(TypedAggregation<?> aggregationClass<O> outputType);

Execute an aggregation operation. The raw results will be mapped to the given entity class.

Parameters:
aggregation The org.springframework.data.mongodb.core.aggregation.Aggregation specification holding the aggregation operations, must not be null.
inputType the inputType where the aggregation operation will read from, must not be null or empty.
outputType The parameterized type of the returned list, must not be null.
Returns:
The results of the aggregation operation.
Since:
1.3
	<O> AggregationResults<O> aggregate(Aggregation aggregationClass<?> inputTypeClass<O> outputType);

Execute an aggregation operation. The raw results will be mapped to the given entity class.

Parameters:
aggregation The org.springframework.data.mongodb.core.aggregation.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 parameterized type of the returned list, must not be null.
Returns:
The results of the aggregation operation.
Since:
1.3
	<O> AggregationResults<O> aggregate(Aggregation aggregationString collectionNameClass<O> outputType);

Execute a map-reduce operation. The map-reduce operation will be formed with an output type of INLINE

Parameters:
inputCollectionName the collection where the map-reduce will read from
mapFunction The JavaScript map function
reduceFunction The JavaScript reduce function
mapReduceOptions Options that specify detailed map-reduce behavior
entityClass The parameterized type of the returned list
Returns:
The results of the map reduce operation
	<T> MapReduceResults<T> mapReduce(String inputCollectionNameString mapFunctionString reduceFunction,
			Class<T> entityClass);

Execute a map-reduce operation that takes additional map-reduce options.

Parameters:
inputCollectionName the collection where the map-reduce will read from
mapFunction The JavaScript map function
reduceFunction The JavaScript reduce function
mapReduceOptions Options that specify detailed map-reduce behavior
entityClass The parameterized type of the returned list
Returns:
The results of the map reduce operation
	<T> MapReduceResults<T> mapReduce(String inputCollectionNameString mapFunctionString reduceFunction,
			MapReduceOptions mapReduceOptionsClass<T> entityClass);

Execute a map-reduce operation that takes a query. The map-reduce operation will be formed with an output type of INLINE

Parameters:
query The query to use to select the data for the map phase
inputCollectionName the collection where the map-reduce will read from
mapFunction The JavaScript map function
reduceFunction The JavaScript reduce function
mapReduceOptions Options that specify detailed map-reduce behavior
entityClass The parameterized type of the returned list
Returns:
The results of the map reduce operation
	<T> MapReduceResults<T> mapReduce(Query queryString inputCollectionNameString mapFunctionString reduceFunction,
			Class<T> entityClass);

Execute a map-reduce operation that takes a query and additional map-reduce options

Parameters:
query The query to use to select the data for the map phase
inputCollectionName the collection where the map-reduce will read from
mapFunction The JavaScript map function
reduceFunction The JavaScript reduce function
mapReduceOptions Options that specify detailed map-reduce behavior
entityClass The parameterized type of the returned list
Returns:
The results of the map reduce operation
	<T> MapReduceResults<T> mapReduce(Query queryString inputCollectionNameString mapFunctionString reduceFunction,
			MapReduceOptions mapReduceOptionsClass<T> entityClass);

Returns org.springframework.data.mongodb.core.geo.GeoResult for all entities matching the given org.springframework.data.mongodb.core.query.NearQuery. Will consider entity mapping information to determine the collection the query is ran against.

Parameters:
near must not be null.
entityClass must not be null.
Returns:
	<T> GeoResults<T> geoNear(NearQuery nearClass<T> entityClass);

Returns org.springframework.data.mongodb.core.geo.GeoResult for all entities matching the given org.springframework.data.mongodb.core.query.NearQuery.

Parameters:
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.
Returns:
	<T> GeoResults<T> geoNear(NearQuery nearClass<T> entityClassString collectionName);

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.

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 org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
Returns:
the converted object
	<T> T findOne(Query queryClass<T> entityClass);

Map the results of an ad-hoc query on the specified collection to a single instance of an object 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 org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
collectionName name of the collection to retrieve the objects from
Returns:
the converted object
	<T> T findOne(Query queryClass<T> entityClassString collectionName);

Determine result of given org.springframework.data.mongodb.core.query.Query contains at least one element.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the criteria used to find a record.
collectionName name of the collection to check for objects.
Returns:
	boolean exists(Query queryString collectionName);

Determine result of given org.springframework.data.mongodb.core.query.Query contains at least one element.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the criteria used to find a record.
entityClass the parameterized type.
Returns:
	boolean exists(Query queryClass<?> entityClass);

Determine result of given org.springframework.data.mongodb.core.query.Query contains at least one element.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the criteria used to find a record.
entityClass the parameterized type.
collectionName name of the collection to check for objects.
Returns:
	boolean exists(Query queryClass<?> entityClassString collectionName);

Map the results of an ad-hoc query on the collection for the entity class to a List 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 org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
Returns:
the List of converted objects
	<T> List<T> find(Query queryClass<T> entityClass);

Map the results of an ad-hoc query on the specified collection to a List 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 org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
collectionName name of the collection to retrieve the objects from
Returns:
the List of converted objects
	<T> List<T> find(Query queryClass<T> entityClassString collectionName);

Returns a document with the given id mapped onto the given class. The collection the query is ran against will be derived from the given target class as well.

Parameters:
<T>
id the id of the document to return.
entityClass the type the document shall be converted into.
Returns:
the document with the given id mapped onto the given target class.
	<T> T findById(Object idClass<T> entityClass);

Returns the document with the given id from the given collection mapped onto the given target class.

Parameters:
id the id of the document to return
entityClass the type to convert the document to
collectionName the collection to query for the document
<T>
Returns:
	<T> T findById(Object idClass<T> entityClassString collectionName);

Triggers findAndModify to apply provided org.springframework.data.mongodb.core.query.Update on documents matching org.springframework.data.mongodb.core.query.Criteria of given org.springframework.data.mongodb.core.query.Query.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the org.springframework.data.mongodb.core.query.Criteria used to find a record and also an optional fields specification.
update the org.springframework.data.mongodb.core.query.Update to apply on matching documents.
entityClass the parameterized type.
Returns:
	<T> T findAndModify(Query queryUpdate updateClass<T> entityClass);

Triggers findAndModify to apply provided org.springframework.data.mongodb.core.query.Update on documents matching org.springframework.data.mongodb.core.query.Criteria of given org.springframework.data.mongodb.core.query.Query.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the org.springframework.data.mongodb.core.query.Criteria used to find a record and also an optional fields specification.
update the org.springframework.data.mongodb.core.query.Update to apply on matching documents.
entityClass the parameterized type.
collectionName the collection to query.
Returns:
	<T> T findAndModify(Query queryUpdate updateClass<T> entityClassString collectionName);

Triggers findAndModify to apply provided org.springframework.data.mongodb.core.query.Update on documents matching org.springframework.data.mongodb.core.query.Criteria of given org.springframework.data.mongodb.core.query.Query taking FindAndModifyOptions into account.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the org.springframework.data.mongodb.core.query.Criteria used to find a record and also an optional fields specification.
update the org.springframework.data.mongodb.core.query.Update to apply on matching documents.
options the FindAndModifyOptions holding additional information.
entityClass the parameterized type.
Returns:
	<T> T findAndModify(Query queryUpdate updateFindAndModifyOptions optionsClass<T> entityClass);

Triggers findAndModify to apply provided org.springframework.data.mongodb.core.query.Update on documents matching org.springframework.data.mongodb.core.query.Criteria of given org.springframework.data.mongodb.core.query.Query taking FindAndModifyOptions into account.

Parameters:
query the org.springframework.data.mongodb.core.query.Query class that specifies the org.springframework.data.mongodb.core.query.Criteria used to find a record and also an optional fields specification.
update the org.springframework.data.mongodb.core.query.Update to apply on matching documents.
options the FindAndModifyOptions holding additional information.
entityClass the parameterized type.
collectionName the collection to query.
Returns:
	<T> T findAndModify(Query queryUpdate updateFindAndModifyOptions optionsClass<T> entityClass,
			String collectionName);

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. The first document that matches the query is returned and also removed from the collection in the database.

The object is converted from the MongoDB native representation using an instance of MongoConverter.

The query is specified as a org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
Returns:
the converted object
	<T> T findAndRemove(Query queryClass<T> entityClass);

Map the results of an ad-hoc query on the specified collection to a single instance of an object of the specified type. The first document that matches the query is returned and also removed from the collection in the database.

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 org.springframework.data.mongodb.core.query.Query which can be created either using the org.springframework.data.mongodb.core.query.BasicQuery or the more feature rich org.springframework.data.mongodb.core.query.Query.

Parameters:
query the query class that specifies the criteria used to find a record and also an optional fields specification
entityClass the parameterized type of the returned list.
collectionName name of the collection to retrieve the objects from
Returns:
the converted object
	<T> T findAndRemove(Query queryClass<T> entityClassString collectionName);

Returns the number of documents for the given org.springframework.data.mongodb.core.query.Query by querying the collection of the given entity class.

Parameters:
query
entityClass must not be null.
Returns:
	long count(Query queryClass<?> entityClass);

Returns the number of documents for the given org.springframework.data.mongodb.core.query.Query querying the given collection.

Parameters:
query
collectionName must not be null or empty.
Returns:
	long count(Query queryString collectionName);

Insert the object into the collection for the entity type of the object to save.

The object is converted to the MongoDB native representation using an instance of 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.

Parameters:
objectToSave the object to store in the collection.
	void insert(Object objectToSave);

Insert the object into the specified collection.

The object is converted to the MongoDB native representation using an instance of 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.

Parameters:
objectToSave the object to store in the collection
collectionName name of the collection to store the object in
	void insert(Object objectToSaveString collectionName);

Insert a Collection of objects into a collection in a single batch write to the database.

Parameters:
batchToSave the list of objects to save.
entityClass class that determines the collection to use
	void insert(Collection<? extends ObjectbatchToSaveClass<?> entityClass);

Insert a list of objects into the specified collection in a single batch write to the database.

Parameters:
batchToSave the list of objects to save.
collectionName name of the collection to store the object in
	void insert(Collection<? extends ObjectbatchToSaveString collectionName);

Insert a mixed Collection of objects into a database collection determining the collection name to use based on the class.

Parameters:
collectionToSave the list of objects to save.
	void insertAll(Collection<? extends ObjectobjectsToSave);

Save the object to the collection for the entity type of the object to save. This will perform an insert if the object is not already present, that is an 'upsert'.

The object is converted to the MongoDB native representation using an instance of 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.

Parameters:
objectToSave the object to store in the collection
	void save(Object objectToSave);

Save the object to the specified collection. This will perform an insert if the object is not already present, that is an 'upsert'.

The object is converted to the MongoDB native representation using an instance of 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 Cobnversion API. See Spring's Type Conversion" for more details.

Parameters:
objectToSave the object to store in the collection
collectionName name of the collection to store the object in
	void save(Object objectToSaveString collectionName);

Performs an upsert. If no document is found that matches the query, a new document is created and inserted by combining the query document and the update document.

Parameters:
query the query document that specifies the criteria used to select a record to be upserted
update the update document that contains the updated object or $ operators to manipulate the existing object
entityClass class that determines the collection to use
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult upsert(Query queryUpdate updateClass<?> entityClass);

Performs an upsert. If no document is found that matches the query, a new document is created and inserted by combining the query document and the update document.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult upsert(Query queryUpdate updateString collectionName);

Performs an upsert. If no document is found that matches the query, a new document is created and inserted by combining the query document and the update document.

Parameters:
query the query document that specifies the criteria used to select a record to be upserted
update the update document that contains the updated object or $ operators to manipulate the existing object
entityClass class of the pojo to be operated on
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult upsert(Query queryUpdate updateClass<?> entityClassString collectionName);

Updates the first object that is found in the collection of the entity class that matches the query document with the provided update document.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
entityClass class that determines the collection to use
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateFirst(Query queryUpdate updateClass<?> entityClass);

Updates the first object that is found in the specified collection that matches the query document criteria with the provided updated document.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateFirst(Query queryUpdate updateString collectionName);

Updates the first object that is found in the specified collection that matches the query document criteria with the provided updated document.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
entityClass class of the pojo to be operated on
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateFirst(Query queryUpdate updateClass<?> entityClassString 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.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
entityClass class that determines the collection to use
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateMulti(Query queryUpdate updateClass<?> entityClass);

Updates all objects that are found in the specified collection that matches the query document criteria with the provided updated document.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateMulti(Query queryUpdate updateString 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.

Parameters:
query the query document that specifies the criteria used to select a record to be updated
update the update document that contains the updated object or $ operators to manipulate the existing object.
entityClass class of the pojo to be operated on
collectionName name of the collection to update the object in
Returns:
the WriteResult which lets you access the results of the previous write.
	WriteResult updateMulti(final Query queryfinal Update updateClass<?> entityClassString collectionName);

Remove the given object from the collection by id.

Parameters:
object
	void remove(Object object);

Removes the given object from the given collection.

Parameters:
object
collection must not be null or empty.
	void remove(Object objectString collection);

Remove all documents that match the provided query document criteria from the the collection used to store the entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query.

Parameters:
query
entityClass
	void remove(Query queryClass<?> entityClass);

Remove all documents that match the provided query document criteria from the the collection used to store the entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query.

Parameters:
query
entityClass
collectionName
	void remove(Query queryClass<?> entityClassString collectionName);

Remove all documents from the specified collection that match the provided query document criteria. There is no conversion/mapping done for any criteria using the id field.

Parameters:
query the query document that specifies the criteria used to remove a record
collectionName name of the collection where the objects will removed
	void remove(Query queryString collectionName);

New to GrepCode? Check out our FAQ X