Class DBQuery
- java.lang.Object
-
- org.mongojack.DBQuery
-
@Deprecated public class DBQuery extends Object
Deprecated.Use com.mongodb.client.model.FiltersBuilder for MongoDB queries.It can be used in place of manually constructed queries (new Document("_id", "FOO")), but is now deprecated.
Any values that are not basic objects (numbers, Strings, booleans, collections etc) that are passed in are attempted to be serialised using Jackson.
Caution needs to be taken when querying entries that are objectIds. The mapper is at this stage unaware whether a field is stored as an ObjectId or not, so you must pass in any values that are stored as ObjectId as type
ObjectId
.The Query is a Bson, which makes it compatible with the methods in the JacksonMongoCollection that accept Bson-query objects, and makes those methods interoperable with Mongo's internal Filters class. But be warned that Query.initialize has to be called before Query.toBsonDocument, or exceptions will result. JacksonMongoCollection takes care of calling initialize for you.
- Since:
- 1.2
- Author:
- James Roper
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DBQuery.AbstractBuilder<Q extends DBQuery.AbstractBuilder>
Deprecated.static class
DBQuery.Query
Deprecated.This is a query builder that is also a valid query that can be passed to MongoDB
-
Constructor Summary
Constructors Constructor Description DBQuery()
Deprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DBQuery.Query
all(String field, Object... values)
Deprecated.The array field contains all of the given valuesstatic DBQuery.Query
all(String field, Collection<?> values)
Deprecated.The array field contains all of the given valuesstatic DBQuery.Query
and(DBQuery.Query... expressions)
Deprecated.All of the given expressions matchstatic DBQuery.Query
elemMatch(String field, DBQuery.Query query)
Deprecated.An element in the given array field matches the given querystatic DBQuery.Query
empty()
Deprecated.Create an empty querystatic DBQuery.Query
exists(String field)
Deprecated.The given field existsstatic DBQuery.Query
greaterThan(String field, Object value)
Deprecated.The field is greater than the given valuestatic DBQuery.Query
greaterThanEquals(String field, Object value)
Deprecated.The field is greater than or equal to the given valuestatic DBQuery.Query
in(String field, Object... values)
Deprecated.The field is in the given set of valuesstatic DBQuery.Query
in(String field, Collection<?> values)
Deprecated.The field is in the given set of valuesstatic DBQuery.Query
is(String field, Object value)
Deprecated.The field is equal to the given valuestatic DBQuery.Query
lessThan(String field, Object value)
Deprecated.The field is less than the given valuestatic DBQuery.Query
lessThanEquals(String field, Object value)
Deprecated.The field is less than or equal to the given valuestatic DBQuery.Query
mod(String field, Number mod, Number value)
Deprecated.The field, modulo the given mod argument, is equal to the valuestatic DBQuery.Query
nor(DBQuery.Query... expressions)
Deprecated.None of the given expressions matchstatic DBQuery.Query
notEquals(String field, Object value)
Deprecated.The field is not equal to the given valuestatic DBQuery.Query
notExists(String field)
Deprecated.The given field doesn't existstatic DBQuery.Query
notIn(String field, Object... values)
Deprecated.The field is not in the given set of valuesstatic DBQuery.Query
notIn(String field, Collection<?> values)
Deprecated.The field is not in the given set of valuesstatic DBQuery.Query
or(DBQuery.Query... expressions)
Deprecated.One of the given expressions matchesstatic DBQuery.Query
regex(String field, Pattern regex)
Deprecated.The given field matches the regular expressionstatic DBQuery.Query
size(String field, int size)
Deprecated.The array field is of the given sizestatic DBQuery.Query
where(String code)
Deprecated.Execute the given JavaScript code as part of the query
-
-
-
Method Detail
-
empty
public static DBQuery.Query empty()
Deprecated.Create an empty query- Returns:
- The empty query
-
is
public static DBQuery.Query is(String field, Object value)
Deprecated.The field is equal to the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
lessThan
public static DBQuery.Query lessThan(String field, Object value)
Deprecated.The field is less than the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
lessThanEquals
public static DBQuery.Query lessThanEquals(String field, Object value)
Deprecated.The field is less than or equal to the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
greaterThan
public static DBQuery.Query greaterThan(String field, Object value)
Deprecated.The field is greater than the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
greaterThanEquals
public static DBQuery.Query greaterThanEquals(String field, Object value)
Deprecated.The field is greater than or equal to the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
notEquals
public static DBQuery.Query notEquals(String field, Object value)
Deprecated.The field is not equal to the given value- Parameters:
field
- The field to comparevalue
- The value to compare to- Returns:
- the query
-
in
public static DBQuery.Query in(String field, Object... values)
Deprecated.The field is in the given set of values- Parameters:
field
- The field to comparevalues
- The value to compare to- Returns:
- the query
-
in
public static DBQuery.Query in(String field, Collection<?> values)
Deprecated.The field is in the given set of values- Parameters:
field
- The field to comparevalues
- The value to compare to- Returns:
- the query
-
notIn
public static DBQuery.Query notIn(String field, Object... values)
Deprecated.The field is not in the given set of values- Parameters:
field
- The field to comparevalues
- The value to compare to- Returns:
- the query
-
notIn
public static DBQuery.Query notIn(String field, Collection<?> values)
Deprecated.The field is not in the given set of values- Parameters:
field
- The field to comparevalues
- The value to compare to- Returns:
- the query
-
mod
public static DBQuery.Query mod(String field, Number mod, Number value)
Deprecated.The field, modulo the given mod argument, is equal to the value- Parameters:
field
- The field to comparemod
- The modulovalue
- The value to compare to- Returns:
- the query
-
all
public static DBQuery.Query all(String field, Collection<?> values)
Deprecated.The array field contains all of the given values- Parameters:
field
- The field to comparevalues
- The values to compare to- Returns:
- the query
-
all
public static DBQuery.Query all(String field, Object... values)
Deprecated.The array field contains all of the given values- Parameters:
field
- The field to comparevalues
- The values to compare to- Returns:
- the query
-
size
public static DBQuery.Query size(String field, int size)
Deprecated.The array field is of the given size- Parameters:
field
- The field to comparesize
- The value to compare- Returns:
- the query
-
exists
public static DBQuery.Query exists(String field)
Deprecated.The given field exists- Parameters:
field
- The field to check- Returns:
- the query
-
notExists
public static DBQuery.Query notExists(String field)
Deprecated.The given field doesn't exist- Parameters:
field
- The field to check- Returns:
- the query
-
or
public static DBQuery.Query or(DBQuery.Query... expressions)
Deprecated.One of the given expressions matches- Parameters:
expressions
- The expressions to test- Returns:
- the query
-
and
public static DBQuery.Query and(DBQuery.Query... expressions)
Deprecated.All of the given expressions match- Parameters:
expressions
- The expressions to test- Returns:
- the query
-
nor
public static DBQuery.Query nor(DBQuery.Query... expressions)
Deprecated.None of the given expressions match- Parameters:
expressions
- The expressions to test- Returns:
- the query
-
regex
public static DBQuery.Query regex(String field, Pattern regex)
Deprecated.The given field matches the regular expression- Parameters:
field
- The field to comareregex
- The regular expression to match with- Returns:
- the query
-
elemMatch
public static DBQuery.Query elemMatch(String field, DBQuery.Query query)
Deprecated.An element in the given array field matches the given query- Parameters:
field
- the array fieldquery
- The query to attempt to match against the elements of the array field- Returns:
- the query
-
where
public static DBQuery.Query where(String code)
Deprecated.Execute the given JavaScript code as part of the query- Parameters:
code
- the JavaScript code- Returns:
- the query
-
-