Skip to content

Instantly share code, notes, and snippets.

@sdawood
Created July 20, 2018 03:33
Show Gist options
  • Select an option

  • Save sdawood/0edba0770dd8ea080204b1ea7cec8fd9 to your computer and use it in GitHub Desktop.

Select an option

Save sdawood/0edba0770dd8ea080204b1ea7cec8fd9 to your computer and use it in GitHub Desktop.
Async Wrapper for DocumentClient.query
async function query(table, {keyConditionExpression, expressionAttributeValues} = {}, options = {}, params = {}) {
const docClient = new AWS.DynamoDB.DocumentClient({...options});
const requiredParams = {
TableName: table,
KeyConditionExpression: keyConditionExpression,
ExpressionAttributeValues: expressionAttributeValues,
ReturnConsumedCapacity: 'TOTAL'
};
return docClient.query({...requiredParams, ...params}).promise();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment