passerine.db.query

Note

This page is automatically generated. If you don’t see anything, this means this sub-module is not meant to be used. If you really want to know what it is, please check out the source code at passerine/db/query.py.

passerine.db.criteria – Query Criteria

class passerine.db.query.Order

Sorting Order Definition

ASC

Ascending Order

alias of ASCENDING

DESC

Descending Order

alias of DESCENDING

class passerine.db.query.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,

criteria.define('foo', 'foo').define('bar', 2)
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:passerine.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