Set

class cerami.datatype.Set(datatype, column_name='', default=None)

A class to represent a Set

A set is a unique collection of primitive values. It can not be a collection of other Sets, Lists or Maps. They are represented in Cerami as arrays of values at the moment.

For example:

class Parent(db.Model):
    friends = Set(String())

parent = Parent(friends=["zac", "mom", "dad"])
__init__(datatype, column_name='', default=None)

constructor for the Set

The translator and condition_type for the set is determined automatically by the datatype passed in.

Parameters
  • datatype – The primitive datatype of each item in the set

  • column_name – a string defining the name of the column on the table

  • default – a default value for the column. It can be a value or function

between(greater_than, less_than)

Build a BetweenExpression

BetweenExpression can be used with the filter() on the model or as a KeyConditionExpression on the sort key of a query

Parameters
  • greater_than – a value that the query is greater than or equal to

  • less_than – a value that the query is less than or equal to

Returns

A BetweenExpression

For example:

Person.scan.filter(Person.age.between(10, 20))
build(val)

build the column value based on the val passed in

building is called automatically by the DynamoDataAttribute when the model is initialized. It will use the default value when present if the val passed in is None

Parameters

val – A value that will be used to build the attribute on the instance

Returns

The passed in val or the default when the default is set

contains(value)

Build a ContainsExpression

Can be used in Filters only, cannot be part of a KeyConditionExpression

Parameters

value – the value to filter upon

Returns

A ContainsExpression

For example:

Person.scan.filter(Painting.colors.contains("red"))
in_(*values)

Build an InExpression

InExpressions can only be used with filter() on the model, it cannot be part of a KeyConditionExpression. The will filter for the table for values that match exactly any of the values passed in as arguments

Parameters

values – anything value to use to filter the table

Returns

An InExpression

For example:

Person.scan.filter(Person.name.in_("Mom", "Dad"))
set_column_name(val)

Update the column_name of this instance

Parameters

value – a string for the new column name