How to Query array of objects(workingDays) key containing only "Tue" in dynamoDb with Scan Operation,I have queried using filter Expression but i am getting no results.
var queryData = {
TableName: tableName,
FilterExpression: "contains (workingDays, :dayVal)",
ExpressionAttributeValues: {
":dayVal": {
S:"Tue"
}
}
};
console.log("getParams ==>", queryData)
dynamodb.scan(queryData, function (err, details) {
if (err) {
console.log(err, err.stack); // an error occurred
callback(err, null)
}
else{
callback(null, details)
}
})
ExpressionAttributeValues in your query contains String ["S"] as 'key' for value 'Tue', where as in your table, 'workingDays' is a list of map object containing value for day keys.
Try below code:
var queryData = {
TableName: tableName,
ExpressionAttributeNames: {
"#workingDays": "workingDays",
},
FilterExpression: "contains (#workingDays, :dayVal)",
ExpressionAttributeValues: {
":dayVal": {
"day":"Tue"
}
}
};
console.log("getParams ==>", queryData)
docClient.scan(queryData, function (err, details) {
if (err) {
console.log(err, err.stack); // an error occurred
// callback(err, null)
}
else{
// callback(null, details)
console.log(details);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With