Query that searches the db for a type 'Company' with the 'Country' field as passed in as an argument, and returns this Company object.
export const companyQuery = async (country: string): Promise<Company> => {
const queryParams: DocumentClient.QueryInput = {
TableName: process.env.DATABASE,
IndexName: 'type-company-GSI',
KeyConditionExpression: '#type = :type AND #country = :country',
ExpressionAttributeNames: {
'#country': 'country',
'#type': 'type',
},
ExpressionAttributeValues: {
':country': country,
':type': 'Company',
},
};
Logger.Log(
'LOGGER COMPANY QUERY ' + (await Database.query<Company>(queryParams))[0],
);
return (await Database.query<Company>(queryParams))[0];
};
Since my logs didn't show the log in this piece of code, it isn't getting that far. The code that calls this function threw a ValidationException: Query condition missed key schema element: company
. Not quite sure what that means or what I'm supposed to change.