in workshop-1/app/monolith-service/service/mysfitsTableClient.py [0:0]
def queryMysfits(queryParam):
logging.info(json.dumps(queryParam))
# Use the DynamoDB API Query to retrieve mysfits from the table that are
# equal to the selected filter values.
response = client.query(
TableName=table_name,
IndexName=queryParam['filter']+'Index',
KeyConditions={
queryParam['filter']: {
'AttributeValueList': [
{
'S': queryParam['value']
}
],
'ComparisonOperator': "EQ"
}
}
)
mysfitList = defaultdict(list)
for item in response["Items"]:
mysfit = {}
mysfit["mysfitId"] = item["MysfitId"]["S"]
mysfit["name"] = item["Name"]["S"]
mysfit["goodevil"] = item["GoodEvil"]["S"]
mysfit["lawchaos"] = item["LawChaos"]["S"]
mysfit["species"] = item["Species"]["S"]
mysfit["thumbImageUri"] = item["ThumbImageUri"]["S"]
mysfitList["mysfits"].append(mysfit)
return json.dumps(mysfitList)