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

Function list

aws-python-rest-api-with-pymongo/item/list.py:18–46  ·  view source on GitHub ↗
(event, context)

Source from the content-addressed store, hash-verified

16
17
18def list(event, context):
19 # create response body object
20 response_body = {}
21
22 # create array for reponse items
23 response_body['response_items'] = []
24
25 # return path parameters with filter key
26 response_body['filter'] = event['multiValueQueryStringParameters']
27
28 # build query with any path parameters
29 query = {}
30 if event['multiValueQueryStringParameters'] is not None:
31 for parameter in event['multiValueQueryStringParameters']:
32 query[parameter] = event['multiValueQueryStringParameters'][parameter][0]
33
34 # create list of items
35 cursor = collection.find(query)
36 for document in cursor:
37 response_body['response_items'].append(document)
38
39 # create response
40 response = {
41 "statusCode": 200,
42 "body": json.dumps(response_body)
43 }
44
45 # return response
46 return response

Callers 1

handlerFunction · 0.50

Calls 1

findMethod · 0.80

Tested by

no test coverage detected