I am trying to query on my table using only the partition key and ignoring the sort key but I get no items.
My global secondary index looks like this:

And my table looks like this:

And this is my query:
const params = {
ExpressionAttributeValues: {
':app': 'app',
},
IndexName: 'glc-development-gsi1',
KeyConditionExpression: 'sk = :app',
TableName: this.tableName,
};
return new Promise((resolve, reject) => {
this.client.query(params, (err, data) => {
console.log(data);
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
According to all the documentation I've read and the other questions on here, this should work and I can't understand why it doesn't. The scan from my index is also empty.
Finally found my solution. DynamoDB stores data in indexes only when both the partition key and the sort key are defined, so my index was empty all the time. The query was fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With