def queryMysfitItems()

in app/mysfits-service/service/mysfitsTableClient.py [0:0]


def queryMysfitItems(filter, value):
    # Use the DynamoDB API Query to retrieve mysfits from the table that are
    # equal to the selected filter values.
    response = client.query(
        TableName=table,
        IndexName=filter+'Index',
        KeyConditions={
            filter: {
                'AttributeValueList': [
                    {
                        'S': value
                    }
                ],
                'ComparisonOperator': "EQ"
            }
        }
    )

    # loop through the returned mysfits and add their attributes to a new dict
    # that matches the JSON response structure expected by the frontend.
    mysfitList = getMysfitsJson(response["Items"])

    # convert the create list of dicts in to JSON
    return json.dumps(mysfitList)