I’m building an application where users are stored in DynamoDB. However, along with the user, there are several other information that also comes in the request.
- Recommendations which is an array of object.
Here is the API request body -
{
"name": "RKReloaded1",
"profileImage": "Sample Image",
"gender": "m",
"fullDescription": "This is to test if we can add recommendation to insider.",
"shortDescription": "HELLO",
"recommendations": [
{
"headline": "New Headline",
"recommendation": "Whatever",
"specialTip": "Hello World",
"dataset": "attractions"
}
]
}
- The above request is stored in the table under
users
. However, I have a new requirement, where I would have to edit a single recommendation. - As I’m currently storing
recommendations
in theusers
table, I’m currently passing theuser_id
and alsorecommendation_id
I want to edit, and then I’m iterating through all the recommendations for the user comparing against therecommendation_id
, which I feel is not the right approach, as the size of the table grows the performance could be impacted. - My question is how do I edit recommendation without passing
user_id
and just usingrecommendation_id
- My current endpoint looks like
/users/{user_id}/recommendations/{id}
, however I’m looking for something like/recommendations/{id}
.
Appreciate the help. Thank you.