Devi
Devi

Reputation: 93

DynamoDB - Query Column name

I'm a newbie to DynamoDB and node.js. I have a requirement to search the dynamoDB table(say Table 1) items/column to find a matching attribute/field name(Not the value) and return the key. This could be a column or a field in the json data. Can you please help me with how to query it? thank you.

Upvotes: 1

Views: 1932

Answers (2)

Guy
Guy

Reputation: 12929

DynamoDB is designed for LOOKUP using keys and not to run a random query on the data. It is a common misunderstanding for people who are coming from relational databases and are used to writing random queries on such data.

If you need to LOOKUP data using a key that is different from the primary key of the table, you can add a secondary index to the table. You can think of it as creating a new table with the same data (or pointers to the main table) but with a different set of keys.

Upvotes: 1

twharmon
twharmon

Reputation: 4282

This requires a Scan, not a Query. Use Scan with caution, since it could be slow and expensive. You likely need to change how items are stored in DynamoDB so you can Query what you need instead of Scan.

Upvotes: 2

Related Questions