AWS DynamoDB simple query from DB


AWS DynamoDB simple query from DB



I have a simple table on DynamoDB
with an id and email



I think I created the indexes and now I just want to query for a specific item with a specific email value.



I keep getting errors on that and cant find the right way.



This is my "describe" of the table:



enter image description here



now how do I query for an item with an email value of "example@example.com"



any help will be highly appreciated!




1 Answer
1



You need to create another index (a Global Secondary Index) only on the email field, if you want to be able to query on only that field. You will have to specify the name of the index you want to use as part of the query.


email



Alternatively, you can do a scan instead of a query.


scan


query





Thanks, can you share an example? And if I have other fields I need to do that for each one? And I thought i added a keyType range there
– Tzook Bar Noy
Jul 1 at 16:32





There are plenty of examples in the official DynamoDB documentation of this sort of thing. And yes you can only run a query against an index (again, this is covered very well in the documentation). docs.aws.amazon.com/amazondynamodb/latest/APIReference/… I don't know what you are asking about keyType. You created a composite primary key that consists of userId and email, so you would need to specify those fields if you want to query against that primary index.
– Mark B
Jul 1 at 16:37


query


keyType


userId


email






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?