As per this link:
Supported Operations on DynamoDB
"You can query only tables that have a composite primary key (partition key and sort key)."
This doesn't seem correct though. I have a table in DynamoDB called 'users' which has a Primary Key that consists of only one attribute 'username'.
And I'm able to query this table just fine in NodeJS using only a 'KeyConditionExpression' on the attribute 'username'. Please see below:
var getUserByUsername = function (username, callback) {
var dynamodbDoc = new AWS.DynamoDB.DocumentClient();
var params = {
TableName: "users",
KeyConditionExpression: "username = :username",
ExpressionAttributeValues: {
":username": username
}
};
dynamodbDoc.query(params, function (err, data) {
if (err) {
console.error("Unable to query. Error:", JSON.stringify(err, null, 2));
callback(err, null);
} else {
console.log("DynamoDB Query succeeded.");
callback(null, data);
}
});
}
This code works just fine. So I'm wondering if the documentation is incorrect or am I missing something?
