如何通过扫描操作在dynamoDb中查询仅包含“ Tue”的对象(workingDays)键数组,我已使用过滤器表达式查询,但没有任何结果。
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)
}
})
答案 0 :(得分:0)
ExpressionAttributeValues 包含字符串[“ S”]作为值“ Tue”的“键”,如表中的“ workingDays” 所示地图对象包含日期键的值。
尝试以下代码:
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);
}
});