I am trying to build a filter expression for my DynamoDB table to use in a scan in a javascript lambda function. My table schema has a field called dateRange
that has the following structure (this is just an example, there could be any number of elements not always 4):
I want to return all items in my table for which the first date
string in dateRange
is greater than some fixed date. Is this possible and if so what would the FilterExpression
look like? I'm basically looking for something like FilterExpression: "#dateRange[0] >= :fixedDate
.
JMLdev I can honestly say to you that the way you use NoSQL database should be a crime haha.
NO! This is not how we do NoSQL. Your first value should be a Range key, simply duplicate the value in another attributes. Storage is cheap, Scans are expensive, you want to model your NoSQL database to be optimised for retrieving information, not saving a tiny amount of space and then end up scanning your entire DB.
So duplicate the attribute, make an LSI if need be with dateRange1
as the Range key (or GSI if you have to), and you are good to go. If the first value is some sort of special value then you can just take the first value out of that list, life will be easier for you want your team then! happy coding.