Reputation: 21
I'm trying to get the data by address on the table.
I'm working on Express environment.
Could you help me with how can I get the data by address, not primary ID?
Upvotes: 2
Views: 100
Reputation: 2476
Retrieving data from DynamoDB by using a non-key attribute is not possible. You can define a global secondary index on your address field. Since addresses are not unique, your best bet might be to construct a complex global secondary index consisting of:
address
ID
That way your global secondary index is unique (because the combination of address and ID is unique) and you can query your global secondary index for a specific address, which will return all records with that address.
Upvotes: 3