Package dev.morphia.query
Interface Query<T>
- Type Parameters:
T
- The java type to query against
- All Superinterfaces:
Iterable<T>
-
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Count the total number of values in the result, ignoring limit and offsetlong
count
(CountOptions options) Count the total number of values in the result, ignoring limit and offsetdefault DeleteResult
delete()
Deletes elements matching this querydelete
(DeleteOptions options) Deletes documents matching this query.Turns off validation (for all calls made after)Turns on validation (for all calls made after); by default validation is onexplain()
Provides information on the query plan.explain
(ExplainVerbosity verbosity) Provides information on the query plan.Adds filters to this query.default T
Deletes an entity from the database and returns it.findAndDelete
(FindAndDeleteOptions options) Deletes an entity from the database and returns it.first()
Gets the first entity in the result set.iterator()
Execute the query and get the results.modify
(ModifyOptions options, UpdateOperator first, UpdateOperator... updates) Create a modify operation based on this querydefault T
modify
(UpdateOperator first, UpdateOperator... updates) Create a modify operation based on this querystream()
Provides aStream
representation of the results of this query.default UpdateResult
Creates an update operation based on this querydefault UpdateResult
update
(UpdateOperator... updates) Creates an update operation based on this queryupdate
(UpdateOptions options, Stage first, Stage... updates) Creates an update operation based on this queryupdate
(UpdateOptions options, UpdateOperator... updates) Creates an update operation based on this queryMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
delete
Deletes elements matching this query- Returns:
- the results
- See Also:
-
filter
Adds filters to this query. This operation is cumulative.- Parameters:
filters
- the filters to add- Returns:
- this
-
count
long count()Count the total number of values in the result, ignoring limit and offset- Returns:
- the count
- Since:
- 1.3
-
count
Count the total number of values in the result, ignoring limit and offset- Parameters:
options
- the options to apply to the count operation- Returns:
- the count
- Since:
- 1.3
-
delete
Deletes documents matching this query. Optionally deleting the first or all matched documents.- Parameters:
options
- the options to apply- Returns:
- the results
-
disableValidation
Turns off validation (for all calls made after)- Returns:
- this
-
enableValidation
Turns on validation (for all calls made after); by default validation is on- Returns:
- this
-
explain
Provides information on the query plan. The query plan is the plan the server uses to find the matches for a query. This information may be useful when optimizing a query.- Returns:
- Map describing the process used to return the query results.
- MongoDB documentation
- explain
-
explain
Provides information on the query plan. The query plan is the plan the server uses to find the matches for a query. This information may be useful when optimizing a query.- Parameters:
verbosity
- the verbosity of the explanation- Returns:
- Map describing the process used to return the query results.
- Since:
- 2.2
- MongoDB documentation
- explain
-
getLoggedQuery
String getLoggedQuery()- Returns:
- The query logged during the previous execution of this query
- Since:
- 2.3
-
findAndDelete
Deletes an entity from the database and returns it.- Returns:
- the deleted entity
-
findAndDelete
Deletes an entity from the database and returns it.- Parameters:
options
- the options to apply- Returns:
- the deleted entity
-
first
Gets the first entity in the result set. Obeys theQuery
offset value.- Returns:
- the only instance in the result, or null if the result set is empty.
- Since:
- 1.5
-
iterator
MorphiaCursor<T> iterator()Execute the query and get the results. -
modify
Create a modify operation based on this query- Parameters:
first
- the first and required update operatorupdates
- lists the set of updates to apply- Returns:
- the modify operation
-
modify
Create a modify operation based on this query- Parameters:
updates
- lists the set of updates to applyfirst
- the first and required update operatoroptions
- the options to apply- Returns:
- the modify operation
- Since:
- 2.3
-
stream
Provides aStream
representation of the results of this query.- Returns:
- the stream
- Since:
- 2.2
-
update
Creates an update operation based on this query- Parameters:
updates
- lists the set of updates to apply- Returns:
- the update operation
-
update
Creates an update operation based on this query- Parameters:
updates
- lists the set of updates to applyoptions
- the options to apply- Returns:
- the update operation
- Since:
- 2.3
-
update
Creates an update operation based on this query- Parameters:
first
- the first and required stagestages
- any remaining stages- Returns:
- the update operation
- Since:
- 2.3
-
update
Creates an update operation based on this query- Parameters:
first
- the first and required stageupdates
- lists the set of updates to applyoptions
- the options to apply- Returns:
- the update operation
- Since:
- 2.3
-