I am using Node.js with DynamoDB. I want to fetch the items in the table that are from the past month. I have a date GSI and the id is also linked to the date. I don't want to use scan because this table will grow. The main issue is that it is not item dependant, and query needs the item partition key which doesn't make sense in my case.
I have tried querying using the GSI on its own and querying the range with just the partition key and with the GSI on it's own. I don't know how to get this right.
TableName: interactionsTable,
IndexName: "interactionDate",
KeyConditionExpression: "interactionDate between :fDay and :lDay",
ExpressionAttributeValues: {
":fDay": firstDayStr,
":lDay": lastDatStr
},
}
I get an error saying that the Key Condition Expression is invalid. Is there a better way to address this problem?