flywheel.fields.conditions module

Query constraints

class flywheel.fields.conditions.Condition[source]

Bases: object

A constraint that will be applied to a query or scan

Attributes:
eq_fields : dict

Mapping of field name to field value

fields : dict

Mapping of field name to (operator, value) tuples

limit : int or dynamo3.Limit

Maximum number of results

scan_limit : int

Maximum number of items to scan in DynamoDB

index_name : str

Name of index to use for a query

classmethod construct(field, op, other)[source]

Create a Condition on a field

Parameters:
field : str

Name of the field to constrain

op : str

Operator, such as ‘eq’, ‘lt’, or ‘contains’

other : object

The value to constrain the field with

Returns:
condition : Condition
classmethod construct_index(name)[source]

Force the query to use a certain index

Parameters:
name : str
Returns:
condition : Condition
classmethod construct_limit(count)[source]

Create a condition that will limit the results to a count

Parameters:
count : int
Returns:
condition : Condition
classmethod construct_scan_limit(count)[source]

Create a condition that will limit the number of items scanned

Parameters:
count : int
Returns:
condition : Condition
query_kwargs(model)[source]

Get the kwargs for doing a table query

scan_kwargs()[source]

Get the kwargs for doing a table scan