我有一个"用户"表,这里有一个示例:
{
username:"haddox",
formattedPhoneNumber:"676767676",
verified: 0,
}
Run Code Online (Sandbox Code Playgroud)
我的愿望是检索formatPhoneNumber包含在电话号码数组中的所有用户(从我的联系人中检索).我创建了一个二级索引,验证为HASH,formattedPhoneNumber为RANGE.这是我的尝试:
var params = {
TableName: "Users",
IndexName: "FormattedPhoneSecondaryIndex",
KeyConditionExpression: "verified = :v AND formattedPhone IN :n",
ExpressionAttributeValues: {
":v":1,
":n": ["672053916", "642117296"]
},
ProjectionExpression: "username, formattedPhoneNumber"
};
dynamodb.query(params, function(err, data) {
if (err)
console.log(JSON.stringify(err, null, 2));
else
console.log(JSON.stringify(data, null, 2));
});
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误: Invalid KeyConditionExpression: Syntax error; token: \":n\", near: \"IN :n\"",
IN关键字有问题吗?也许有另一种方法来实现这一目标?