MCPcopy
hub / github.com/serverless/examples / update

Function update

aws-python-rest-api-with-faunadb/todos/update.py:10–32  ·  view source on GitHub ↗
(event, context)

Source from the content-addressed store, hash-verified

8from faunadb import query
9
10def update(event, context):
11 data = json.loads(event['body'])
12 if 'text' not in data or 'checked' not in data:
13 logging.error("Validation Failed")
14 raise Exception("Couldn't update the todo item.")
15
16 data = {
17 'text': data['text'],
18 'checked': data['checked'],
19 'updatedAt': query.time('now')
20 }
21
22 # update the todo in the database
23 ref = Ref(TODOS, event['pathParameters']['id'])
24 updated = client.query(query.update(ref, {'data': data}))
25
26 # create a response
27 response = {
28 "statusCode": 200,
29 "body": json.dumps(make_result(updated))
30 }
31
32 return response

Callers

nothing calls this directly

Calls 3

make_resultFunction · 0.90
errorMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected