Reputation: 551
I have a table in dynamodb like this:
TableName : "User",
KeySchema: [
{ AttributeName: "id", KeyType: "HASH"} //Partition key
],
AttributeDefinitions: [
{ AttributeName: "id", AttributeType: "S" }
],
ProvisionedThroughput: {
ReadCapacityUnits: 10,
WriteCapacityUnits: 10
}
Now I am trying to search a user:
var params = {
TableName: 'User',
FilterExpression: 'contains(id, :value)',
ExpressionAttributeValues: {
':value': 'ronaldo'
}
};
dynamodb.scan(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
It's very simple, but I got a lot errors:
"message": "Expected params.ExpressionAttributeValues['value'] to be a structure"
Anyone got this ?
Upvotes: 0
Views: 2310
Reputation: 1120
You can try this code: I got the same issue. Here structure meaning we should supply DataType while passing the value to It.
var params = {
TableName: 'User',
FilterExpression: 'contains(id, :value)',
ExpressionAttributeValues: {
':value': {
'S': 'ronaldo'
}
}
};
dynamodb.scan(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
Where S means String Data type.
Upvotes: 3