Returning only the subset for response from dynamdb scan

做~自己de王妃 提交于 2020-12-13 03:28:20

问题


the use case that I am trying to achieve is:

To check if there is any existing bid on the load that has been posted.

there 2 different tables

  1. "load" which has information on the load

  2. "bid" which has information of bid on loads.

Now I read that dynamodb can't support joins as RDS does.

How can I check there is an exiting bid on a load?

My approach here was to scan the "bid" table with load_id and bid_by and send the information to the front end and do the rest of the operation there.

here is a code snippet:

dynamo_client = boto3.resource('dynamodb')
loadeo_loadBoard = dynamo_client.Table('loadeo_bid')

load_id = event['queryStringParameters']['load_id']
company_name = event['queryStringParameters']['companyName']

response = loadeo_loadBoard.scan(
    FilterExpression = Attr('posted_by_company').eq(company_name) & Attr('load_id').eq(load_id)
    )
#sending to sendResponse function as the response generated by scan will have nested json 
return sendResponse(response,company_name)

Here I need to send only the load_id and the bid_amount present in "bid" table, is there a way I can achieve that?

and also is there a way I can achieve joins for my use case?

来源:https://stackoverflow.com/questions/64985504/returning-only-the-subset-for-response-from-dynamdb-scan

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!