MCPcopy Create free account
hub / github.com/serverless/examples / TodoModel

Class TodoModel

aws-python-rest-api-with-pynamodb/todos/todo_model.py:8–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class TodoModel(Model):
9 class Meta:
10 table_name = os.environ['DYNAMODB_TABLE']
11 if 'ENV' in os.environ:
12 host = 'http://localhost:8000'
13 else:
14 region = 'eu-central-1'
15 host = 'https://dynamodb.eu-central-1.amazonaws.com'
16
17 todo_id = UnicodeAttribute(hash_key=True, null=False)
18 text = UnicodeAttribute(null=False)
19 checked = BooleanAttribute(null=False)
20 createdAt = UTCDateTimeAttribute(null=False, default=datetime.now())
21 updatedAt = UTCDateTimeAttribute(null=False)
22
23 def save(self, conditional_operator=None, **expected_values):
24 self.updatedAt = datetime.now()
25 super(TodoModel, self).save()
26
27 def __iter__(self):
28 for name, attr in self._get_attributes().items():
29 yield name, attr.serialize(getattr(self, name))

Callers 1

createFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected