def handle(event, context): db = Database() drivers = db.get_all(Driver, as_dict=True) response = { 'statusCode': 200, 'body': json.dumps(drivers), } return response
def handle(event, context): db = Database() partner = db.get_all(Partner, as_dict=True) response = { 'statusCode': 200, 'body': json.dumps(partner), } return response
def handle(event, context): db = Database() users = db.get_all(User, as_dict=True) response = { 'statusCode': 200, 'headers': { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Credentials': True }, 'body': json.dumps(users), } return response
def handle(event, context): db = Database() products = [] for product in db.get_all(Product): products.append({ 'product': object_to_dict(product), 'partner': object_to_dict(product.partner) }) response = { 'statusCode': 200, 'body': json.dumps(products), } return response
def handle(event, context): db = Database() adresses = [] for adress in db.get_all(Adress, as_dict=True): if adress.get('id_collector'): adress.append({ 'adress': adress, 'collector': object_to_dict(adress.collector) }) else: user = db.get(User, adress.id_user) adress.append({ 'adress': adress, 'user': object_to_dict(user) }) response = { 'statusCode': 200, 'body': json.dumps(adresses), } return response