Skip to content

Instantly share code, notes, and snippets.

@enricop89
Created October 9, 2021 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricop89/89557d4374412fde989135b017eb8bd1 to your computer and use it in GitHub Desktop.
Save enricop89/89557d4374412fde989135b017eb8bd1 to your computer and use it in GitHub Desktop.
GSI Query Example
function findBookByGenreAndYear({genre, startYear, endYear}) {
var params = {
ExpressionAttributeValues: {
":genre": {"S": genre},
":startYear": {"N": startYear},
":endYear": {"N": endYear},
},
ExpressionAttributesNames:{
"#genre": "Genre",
"#y": "Year",
},
KeyConditionExpression: "#genre = :genre AND #y BETWEEN :startYear AND :endYear",
TableName: "Library",
IndexName: "GSI_1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment