(event, context)
| 8 | from faunadb import query |
| 9 | |
| 10 | def 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 |
nothing calls this directly
no test coverage detected