tori.db.criteria¶
tori.db.criteria
– Query Criteria¶
-
class
tori.db.criteria.
Order
¶ Sorting Order Definition
-
ASC
¶ Ascending Order
alias of
ASCENDING
-
DESC
¶ Descending Order
alias of
DESCENDING
-
-
class
tori.db.criteria.
Query
(alias)¶ Criteria
Note
The current implementation does not support filtering on associated entities.
-
criteria
¶ Expression Criteria
-
define
(variable_name=None, value=None, **definition_map)¶ Define the value of one or more variables (known as parameters).
Parameters: - variable_name (str) – the name of the variable (for single assignment)
- value – the value of the variable (for single assignment)
- definition_map – the variable-to-value dictionary
This method is usually recommended be used to define multiple variables like the following example.
criteria.define(foo = 'foo', bar = 2)
However, it is designed to support the assign of a single user. For instance,
-
expect
(statement)¶ Define the condition / expectation of the main expression.
Parameters: statement (str) – the conditional statement This is a shortcut expression to define expectation of the main expression. The main expression will be defined automatically if it is undefined. For example,
c = Query() c.expect('foo = 123')
is the same thing as
c = Query() c.criteria = c.new_criteria() c.criteria.expect('foo = 123')
-
join
(property_path, alias)¶ Define a join path
-
join_map
¶ A join map
-
limit
(limit)¶ Define the filter limit
Parameters: limit (int) – the filter limit
-
new_criteria
()¶ Get a new expression for this criteria
Return type: tori.db.expression.Criteria
-
order
(field, direction=<class 'ASCENDING'>)¶ Define the returning order
Parameters: - field (str) – the sorting field
- direction – the sorting direction
-
start
(offset)¶ Define the filter offset
Parameters: offset (int) – the filter offset
-
where
(key_or_full_condition, filter_data=None)¶ Define the condition
Deprecated since version 3.1: Starting in Tori 3.0, the new way to query will be.
Parameters: - key_or_full_condition (str or dict) – either the key of the condition (e.g., a field name, $or, $gt etc.)
- filter_data – the filter data associating to the key
-