SearchAttributes

SearchAttribute

class cerami.request.search_attribute.SearchAttribute(value=None)

The base class for all attributes used for BaseRequest.add_attribute()

All Request objects have a request_attributes dict whose keys represent options for the request and values are different children of this base class. Request.build() iterates all of these attributes and calls this class’ build method.

All Request methods return a reference to the caller, so it is possible to chain multiple methods of the same thing together. For example:

Model.filter(Model.column1 == 1).filter(Model.column2 == 2)

The search attribute needs to decide how to handle duplicate calls. It may want to overwrite the first value, or do something to append them, That logic is handled by SearchAttribute.add()

value

Anything. It will be up to the build() method how to convert this value into a format suitable for DynamoDb

__init__(value=None)

constructor for the SearchAttribute

Parameters

value – it can by anything - whatever should be associated with the name

add(value)

setter for value

All Request methods return a reference to the caller, so it is possible to chain multiple methods of the same thing together. For example, Model.filter(Model.column1 == 1).filter(Model.column2 == 2)

The search attribute needs to decide how to handle duplicate calls. It may want to overwrite the first value, or do something to append them, That logic is handled by SearchAttribute.add()

Parameters

value – A new value to be manipulated by the class

build()

build the SearchAttribute, which is called

Request has a request_attributes dict whose keys represent options for the request and values are different children of this base class. Request.build() iterates all of these attributes and calls this SearchAttribute.build().

Returns

the value

DictAttribute

class cerami.request.search_attribute.DictAttribute(value=None)

A class for representing SearchAttributes as a dict

__init__(value=None)

constructor for the SearchAttribute

Parameters: value: it should be a dict, or will default to an empty one

add(value_dict)

Update the self.value with the value_dict

This allows for chaining or the same call to overwrite any keys that were previously present with the new values represented in value_dict

build()

build the SearchAttribute, which is called

Request has a request_attributes dict whose keys represent options for the request and values are different children of this base class. Request.build() iterates all of these attributes and calls this SearchAttribute.build().

Returns

the value

ProjectionExpressionAttribute

class cerami.request.search_attribute.ProjectionExpressionAttribute(value=None)

A class specifically to be used with the Projectable mixin

__init__(value=None)

constructor for the SearchAttribute

Parameters

value – it should be an array of BaseExpressions.

add(expression)

Update self.value by appending the new expression

Parameters

expression – a BaseExpression

build()

Build a comma separated list of all expressions in value

ProjectionExpression is a comma separated list of all datatypes that should be returned by the request. All expressions in the value array are just empty expressions containing the Datatype.column_name

Returns

A string of all expressions separated by commas

QueryExpressionAttribute

class cerami.request.search_attribute.QueryExpressionAttribute(value=None)

A class specifically to be used for QueryRequest.key()

__init__(value=None)

constructor for the Search Attribute

Parameters

value – it should be an array of BaseExpressions

add(expression)

Update self.value by appending the new expression

Parameters

expression – a BaseExpression

build()

Build a list of expressions separated by and

KeyConditionExpression is a string of all different expressions that identify the keys of the table. It is the primary keys under most situation or can be whatever datatypes identify the index used for the query.

UpdateExpressionAttribute

class cerami.request.search_attribute.UpdateExpressionAttribute(value=None)

A SearchAttribute used exclusively for UpdateRequest

Its value is a dict, whose keys are one the update actions ADD | SET | DELETE | UPDATE The value of each corresponding key is an array of expressions. This is so each action is unique during the build process and the expressions are comma separated:

Model.add(Model.a_number(10)).add(Model.other_number(20))
# becomes
"ADD a_number 10, other_number 20"
__init__(value=None)

constructor for the SearchAttribute

Parameters

value – it should be a dict whose keys are arrays of expressions

add(update_action)

Update the self.value with the update_action

It will create the array automatically if the key is missing or will append it

Parameters

update_action – an UpdateAction object

build()

return all grouped expressions of value

iterate over all keys and create a comma separated string of all expressions for each corresponding value array.

Returns

a string of all expressions

UpdateAction

class cerami.request.search_attribute.UpdateAction(action, expression)

A class used specificallly for UpdateExpressionAttributes

__init__(action, expression)

constructor for UpdateAction

Parameters
  • action – a string ADD | SET | DELETE | UPDATE

  • expression – a BaseExpression