java.lang.Iterable<T>
,
com.mongodb.client.MongoIterable<T>
,
QueryResults
<T>
QueryImpl
public interface Query<T> extends QueryResults<T>, com.mongodb.client.MongoIterable<T>
CriteriaContainer and(Criteria... criteria)
criteria
- the clauses to 'and' together
batchSize
in interface
com.mongodb.client.MongoIterable<
T
>
value
- must be >= 0. A value of 0 indicates the server default.
FindOptions.batchSize(int)
FindOptions.comment(String)
comment
- the comment to add
FieldEnd<? extends CriteriaContainer> criteria(java.lang.String field)
field
- the field
Query<T> disableValidation()
Query<T> enableValidation()
java.util.Map<java.lang.String,java.lang.Object> explain()
java.util.Map<java.lang.String,java.lang.Object> explain(FindOptions options)
options
- the options to apply to the explain operation
FieldEnd<? extends Query<T>> field(java.lang.String field)
createQuery(Ent.class).field("count").greaterThan(7)...
field
- the field
Query<T> filter(java.lang.String condition, java.lang.Object 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
condition
- the condition to apply
value
- the value to apply against
options.modifier("$hint", idxName)
idxName
- the index name to hint
FindOptions.hint(DBObject)
value
- must be >= 0. A value of 0 indicates no limit. For values < 0, use
FindOptions.batchSize(int)
which
is the preferred method
FindOptions.limit(int)
Specify the inclusive lower bound for a specific index in order to constrain the results of this query.
You can chain key/value pairs to build a constraint for a compound index. For instance:
query.lowerIndexBound(new
BasicDBObject("a", 1).append("b", 2));
to build a constraint on index
{"a", "b"}
lowerBound
- The inclusive lower bound.
FindOptions.min(DBObject)
value
- must be > 0. A value < 0 indicates no limit
FindOptions.maxTime(long, TimeUnit)
instead
maxTime
- must be > 0. A value < 0 indicates no limit
maxTimeUnit
- the unit of time to use
FindOptions.maxTime(long, TimeUnit)
value
- must be >= 0
FindOptions.skip(int)
order("-age")
(descending order)
order("age, date")
order("age,-date")
(age ascending, date descending)
sort
- the sort order to apply
order(Meta.textScore())
({textScore : { $meta: "textScore" }})
sort
- the sort order to apply
sorts
- the sort order to apply
field
- the field to project
include
- true to include the field in the results
ReadPreference.secondary()
,
ReadPreference.secondaryPreferred()
,
FindOptions.readPreference(ReadPreference)
,
ReadPreference.secondary()
,
ReadPreference.secondaryPreferred()
ReadPreference.primary()
,
FindOptions.readPreference(ReadPreference)
,
ReadPreference.primary()
,
ReadPreference.primaryPreferred()
Query<T> retrieveKnownFields()
include
- true if the fields should be included in the results. false to exclude them.
fields
- the fields in question
FindOptions.returnKey(boolean)
Query<T> search(java.lang.String text)
text
- the text to search for
Query<T> search(java.lang.String text, java.lang.String language)
text
- the text to search for
language
- the language to use during the search
Specify the exclusive upper bound for a specific index in order to constrain the results of this query.
You can chain key/value pairs to build a constraint for a compound index. For instance:
query.upperIndexBound(new
BasicDBObject("a", 1).append("b", 2));
to build a constraint on index
{"a", "b"}
upperBound
- The exclusive upper bound.
FindOptions.max(DBObject)
@Deprecated Query<T> useReadPreference(com.mongodb.ReadPreference readPref)
readPref
- the ReadPreference to use
ReadPreference
,
FindOptions.readPreference(ReadPreference)
keys()
List<Key<T>>
) This method is provided as a convenience;
List<Key<T>>
) This method is provided as a convenience;
options
- the options to apply to the find operation
MorphiaKeyCursor<T> keys()
MorphiaCursor<Key<T>>
)
MorphiaKeyCursor<T> keys(FindOptions options)
MorphiaCursor<Key<T>>
)
options
- the options to apply to the find operation
options
- the options to apply to the find operation
count()
instead
long count()
long count(CountOptions options)
options
- the options to apply to the count operation
find(FindOptions)
instead
options
- the options to apply to the find operation
keys()
instead
@Deprecated MorphiaIterator<T,T> fetchEmptyEntities(FindOptions options)
keys(FindOptions)
instead
options
- the options to apply to the find operation
T first(FindOptions options)
Query
offset value.
options
- the options to apply to the find operation
MongoIterable.first()
Query
offset value.
Query
offset value.
options
- the options to apply to the find operation
MongoIterable.first()
instead
Query
offset value.
MongoIterable.first()
instead
Query
offset value.
options
- the options to apply to the find operation
FindOptions
and use
find(FindOptions)
instead
tail(true);
tail(boolean)
FindOptions
and use
find(FindOptions)
instead. This can be replicated using
findOptions.cursorType (awaitData ? TailableAwait : Tailable)
awaitData
- passes the awaitData to the cursor