I am using the following code for Node.js to get a item from dynamodb
var params = {
AttributesToGet: [
"password"
],
TableName : 'foo',
Key : {
"username" : {
"S" : "bar"
},
}
}
db.getItem(params, function(err, data) {
if (err) {
console.log(err); // an error occurred
}
else {
console.log(data); // successful response
res.send(data);
}
return next();
});
but there are cases where I do not know the key value for fetching the items. I want to know whether I can fetch items based on attribute values. something like the following :
var params = {
AttributesToGet: [
"password"
],
TableName : 'foo',
Attribute : {
"userlocation" : {
"S" : "EUROPE"
},
}
}
You can create global secondary indexes on additional attributes you want to query. http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html