public interface Query<T> extends QueryResults<T>, Cloneable
Modifier and Type | Method and Description |
---|---|
CriteriaContainer |
and(Criteria... criteria) |
Query<T> |
batchSize(int value)
Batch-size of the fetched result (cursor).
|
Query<T> |
clone()
Creates and returns a copy of this
Query . |
FieldEnd<? extends CriteriaContainerImpl> |
criteria(String field)
Criteria builder interface
|
Query<T> |
disableCursorTimeout()
Disables cursor timeout on server.
|
Query<T> |
disableSnapshotMode()
Disable snapshotted mode (default mode).
|
Query<T> |
disableValidation()
Turns off validation (for all calls made after)
|
Query<T> |
enableCursorTimeout()
Enables cursor timeout on server.
|
Query<T> |
enableSnapshotMode()
Enabled snapshotted mode where duplicate results (which may be updated during the lifetime of the cursor) will not be returned.
|
Query<T> |
enableValidation()
Turns on validation (for all calls made after); by default validation is on
|
FieldEnd<? extends Query<T>> |
field(String field)
Fluent query interface:
createQuery(Ent.class).field("count").greaterThan(7)... |
Query<T> |
filter(String condition,
Object value)
Create a filter based on the specified condition and value.
|
int |
getBatchSize()
Returns the batch size
|
com.mongodb.DBCollection |
getCollection()
Returns the
DBCollection of the Query . |
Class<T> |
getEntityClass()
Returns the entity
Class . |
com.mongodb.DBObject |
getFieldsObject()
Returns the Mongo fields
DBObject . |
int |
getLimit()
Returns the limit
|
int |
getOffset()
Returns the offset.
|
com.mongodb.DBObject |
getQueryObject()
Returns the Mongo query
DBObject . |
com.mongodb.DBObject |
getSortObject()
Returns the Mongo sort
DBObject . |
Query<T> |
hintIndex(String idxName)
Hints as to which index should be used.
|
Query<T> |
limit(int value)
Limit the fetched result set to a certain number of values.
|
Query<T> |
offset(int value)
Starts the query results at a particular zero-based offset.
|
CriteriaContainer |
or(Criteria... criteria) |
Query<T> |
order(String condition)
Sorts based on a property (defines return order).
|
Query<T> |
queryNonPrimary()
Route query to non-primary node
|
Query<T> |
queryPrimaryOnly()
Route query to primary node
|
Query<T> |
retrievedFields(boolean include,
String... fields)
Limits the fields retrieved
|
Query<T> |
retrieveKnownFields()
Limits the fields retrieved to those of the query type -- dangerous with interfaces and abstract classes
|
Query<T> |
skip(int value)
Deprecated.
use @{link #offset(int)} instead
|
String |
toString()
Generates a string that consistently and uniquely specifies this query.
|
Query<T> |
useReadPreference(com.mongodb.ReadPreference readPref)
Route query ReadPreference
|
Query<T> |
where(org.bson.types.CodeWScope js)
Limit the query using this javascript block; only one per query
|
Query<T> |
where(String js)
Limit the query using this javascript block; only one per query
|
Query<T> filter(String condition, Object value)
Create a filter based on the specified condition and value.
Note: Property is in the form of "name op" ("age >").
Valid operators are ["=", "==","!=", "<>", ">", "<", ">=", "<=", "in", "nin", "all", "size", "exists"]
Examples:
filter("yearsOfOperation >", 5)
filter("rooms.maxBeds >=", 2)
filter("rooms.bathrooms exists", 1)
filter("stars in", new Long[]{3, 4}) //3 and 4 stars (midrange?)
filter("quantity mod", new Long[]{4, 0}) // customers ordered in packs of 4)
filter("age >=", age)
filter("age =", age)
filter("age", age)
(if no operator, = is assumed)filter("age !=", age)
filter("age in", ageList)
filter("customers.loyaltyYears in", yearsList)
You can filter on id properties if this query is restricted to a Class
FieldEnd<? extends Query<T>> field(String field)
createQuery(Ent.class).field("count").greaterThan(7)...
FieldEnd<? extends CriteriaContainerImpl> criteria(String field)
CriteriaContainer and(Criteria... criteria)
CriteriaContainer or(Criteria... criteria)
Query<T> where(org.bson.types.CodeWScope js)
Query<T> order(String condition)
Sorts based on a property (defines return order). Examples:
order("age")
order("-age")
(descending order)order("age, date")
order("age,-date")
(age ascending, date descending)Query<T> limit(int value)
value
- must be >= 0. A value of 0 indicates no limit.Query<T> batchSize(int value)
value
- must be >= 0. A value of 0 indicates the server default.Query<T> offset(int value)
value
- must be >= 0Query<T> skip(int value)
value
- Query<T> enableValidation()
Query<T> retrievedFields(boolean include, String... fields)
Query<T> retrieveKnownFields()
Query<T> enableSnapshotMode()
Query<T> disableSnapshotMode()
Query<T> useReadPreference(com.mongodb.ReadPreference readPref)
String toString()
Generates a string that consistently and uniquely specifies this query. There is no way to convert this string back into a query and there is no guarantee that the string will be consistent across versions.
In particular, this value is useful as a key for a simple memcache query cache.
int getOffset()
offset(int)
int getLimit()
limit(int)
int getBatchSize()
batchSize(int)
com.mongodb.DBObject getQueryObject()
DBObject
.com.mongodb.DBObject getSortObject()
DBObject
.com.mongodb.DBObject getFieldsObject()
DBObject
.com.mongodb.DBCollection getCollection()
DBCollection
of the Query
.Copyright © 2013. All Rights Reserved.