Strings

String

class cerami.datatype.String(translator_cls=<class 'cerami.datatype.translator.string_translator.StringTranslator'>, default=None, column_name='')

A class to represent any primitive String

BaseString

class cerami.datatype.BaseString(translator_cls=<class 'cerami.datatype.translator.string_translator.StringTranslator'>, default=None, column_name='')

A Base class for all String datatypes

__init__(translator_cls=<class 'cerami.datatype.translator.string_translator.StringTranslator'>, default=None, column_name='')

constructor for the BaseString

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

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

  • translator_cls – A translator class to manipulate data to/from dynamodb. Defaults to the StringTranslator

begins_with(value)

Build a BeginsWithExpression

Can be used in Filters or KeyConditionExpressions to create a begins_with expression.

Parameters

value – a substring to check if the column begins with

Returns

A BeginsWithExpression

For example:

Person.scan.filter(Person.name.begins_with("Mo"))
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(Person.name.contains("om"))
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