Reputation: 21
I'm new to Amazon DynamoDB and I want to get records according to creator id which is in parts object. so how could i fetch data from db according to creator id.
{ "id": "123", "parts": { "name": "xyz", "createdBy": "1", } }
so how could i query and get data where parts.createdBy id is 1. and i am using AWS.document.client.
Upvotes: 0
Views: 2943
Reputation: 2985
it works a little bit different in DynamoDB, you need to create an index to be able to Query data in DynamoDB, you can't query data using the nested value parts.createdBy
,
when you write your data to DynamoDB, you will need to extract the ID from within the object and place it in an attribute/column and create an Index in the table using that value
have a look on this article, Alex is an expert on DynamoDB and I'm confident that after you read it, you will be able to achieve what you are looking for:
https://www.alexdebrie.com/posts/dynamodb-one-to-many/
Upvotes: 1