I am having a hard time finding a useful example for a scan with FilterExpression on a DynamoDB table. I am using the javascript SDK in the browser.
I would like to scan my table and return only those records that have HASH field "UID" values within an array I pass to the Scan
Lets say I have an array of unique ids that are the hash field of my table I would like to query these records from my DynamoDB table.
Something like below
var idsToSearch=['123','456','789'] //array of the HASH values I would like to retrieve
var tableToSearch = new AWS.DynamoDB();
var scanParams = {
"TableName":"myAwsTable",
"AttributesToGet":['ID','COMMENTS','DATE'],
"FilterExpression":"'ID' in "+idsToSearch+""
}
tableToSearch.scan(scanParams), function(err,data){
if (err) console.log(err, err.stack); //error handler
else console.log(data); //success response
})