I have a "Users" table, here is a sample :
{
username:"haddox",
formattedPhoneNumber:"676767676",
verified: 0,
}
My wish is to retrieve all users whose formattedPhoneNumber is contained in an array of phone numbers (retrieved from my contacts). I created a secondary index, with verified as HASH and formattedPhoneNumber as RANGE. Here is my try :
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));
});
But I get the following error : Invalid KeyConditionExpression: Syntax error; token: ":n", near: "IN :n"",
Is there something wrong with the IN keyword ?
Maybe there is another way to achieve this ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…