E - the type of entities being queried.public class MongoQuery<E extends MongoEntity> extends Query<MongoQuery<E>,E,MongoConstraint>
descriptor, limit, MAX_LIST_SIZE, mixing, skip| Modifier | Constructor and Description |
|---|---|
protected |
MongoQuery(EntityDescriptor descriptor)
Creates a new query for the given descriptor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
count()
Executes the query and counts the number of results.
|
void |
delete()
Deletes all matches using the
BaseMapper.delete(BaseEntity) of the appropriate mapper. |
MongoQuery<E> |
eq(Mapping key,
Object value)
Adds a constraint which ensures that the given field contains the given value.
|
MongoQuery<E> |
eqIgnoreNull(Mapping field,
Object value)
Adds a constraint which ensures that the given field contains the given value.
|
boolean |
exists()
Determines if the query would have at least one matching entity.
|
MongoQuery<E> |
fields(Mapping... fieldsToReturn)
Limits the fields being returned to the given list.
|
FilterFactory<MongoConstraint> |
filters() |
void |
iterate(Function<E,Boolean> resultHandler)
Calls the given function on all items in the result, as long as it returns true.
|
MongoQuery<E> |
limit(int limit)
Specifies the max. number of items to fetch.
|
MongoQuery<E> |
limit(int skip,
int limit)
Adds a limit to the query.
|
MongoQuery<E> |
orderAsc(Mapping field)
Adds a sort constraint to order by the given field ascending.
|
MongoQuery<E> |
orderDesc(Mapping field)
Adds a sort constraint to order by the given field descending.
|
MongoQuery<E> |
skip(int skip)
Specifies the number of items to skip before items are added to the result.
|
String |
toString() |
void |
truncate()
Deletes all matches using the capabilities of the underlying database.
|
MongoQuery<E> |
where(MongoConstraint constraint)
Applies the given contraints to the query.
|
ne, queryStringfailOnOverflow, first, getDescriptor, getLimit, iterateAll, one, queryFirst, queryList, queryOneprotected MongoQuery(EntityDescriptor descriptor)
descriptor - the descriptor of the entities being queriedpublic MongoQuery<E> fields(Mapping... fieldsToReturn)
fieldsToReturn - specified the list of fields to returnpublic MongoQuery<E> eq(Mapping key, Object value)
Queryeq in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>key - the name of the field to filter onvalue - the value to filter onpublic MongoQuery<E> eqIgnoreNull(Mapping field, Object value)
QueryIf the given value is null, the constraint is skipped.
eqIgnoreNull in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>field - the field to checkvalue - the value to filter onpublic MongoQuery<E> where(MongoConstraint constraint)
Querywhere in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>constraint - the constraint which has to be fullfilledpublic MongoQuery<E> orderAsc(Mapping field)
QueryorderAsc in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>field - the field to order by.public MongoQuery<E> orderDesc(Mapping field)
QueryorderDesc in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>field - the field to order by.public MongoQuery<E> limit(int skip, int limit)
skip - the number of items to skip (used for pagination).limit - the max. number of items to return (exluding those who have been skipped).public MongoQuery<E> skip(int skip)
BaseQueryskip in class BaseQuery<MongoQuery<E extends MongoEntity>,E extends MongoEntity>skip - the number of items to skip. Value <= 0 are ignored.public MongoQuery<E> limit(int limit)
BaseQuerylimit in class BaseQuery<MongoQuery<E extends MongoEntity>,E extends MongoEntity>limit - the max. number of items to fetch. Value <= 0 indicate "unlimited".public void iterate(Function<E,Boolean> resultHandler)
BaseQueryNote that this method is intended for large results as not all items in the result need to be kept in memory when iterating through them.
iterate in class BaseQuery<MongoQuery<E extends MongoEntity>,E extends MongoEntity>resultHandler - the handle to be invoked for each item in the resultpublic long count()
Querycount in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>public boolean exists()
Queryexists in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>public void delete()
QueryBaseMapper.delete(BaseEntity) of the appropriate mapper.
Be aware that this might be slow for very large result sets.
delete in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>public void truncate()
QueryTherefore no checks or anything will be invoked for the deleted entities.
Use this for larger result sets where integrity and constraints do not matter or are managed manually.
truncate in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>public FilterFactory<MongoConstraint> filters()
filters in class Query<MongoQuery<E extends MongoEntity>,E extends MongoEntity,MongoConstraint>Copyright © 2018. All rights reserved.