0
Here is the table structure. In posts column it is a list of strings
所以我一直在閱讀並嘗試使用filterExpression和'contains'。什麼文件說,node.js中只需使用一個含有B其中一個可以是一個列表,並b對我來說是一個字符串我正在尋找。
DynamoDB query with lambda(node.js)FilterExpression using
var db = new doc.DynamoDB();
var params = {
TableName: "WIT_Search",
KeyConditionExpression: "#type = :tag and #key between :start AND :end",
FilterExpression: "#tag contains :post",
ExpressionAttributeNames: {
"#type": "type",
"#tag": "posts",
"#key": "key",
},
ExpressionAttributeValues: {
":tag": "tag",
":start": tag+"_",
":end": tag+"_999",
":post": postID
}
};
console.log(params);
db.query(params, function(err, data) {
if (err) {
console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
} else {
console.log("Query succeeded.");
console.log('Count =',data.Items.length);
if (data.Items.length > 0){
console.log("post exists in tag");
}else{
console.log("post doesnt exist in tag");
}
}
});
每當我做測試它給了我這個消息:
Unable to query. Error: {
"message": "Invalid FilterExpression: Syntax error; token: \"contains\", near: \"#tag contains (\"",
"code": "ValidationException",
}
在AWS控制檯怪異的事情它的工作原理沒有問題,只是使用拉姆達與節點。 JS它給這個錯誤。
太棒了,謝謝!無法找到一個很好的例子! –