Help - Issue with editing a nested object

dynamodb

#1

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.

  1. 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"
        }
    ]
}
  1. 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.
  2. As I’m currently storing recommendations in the users table, I’m currently passing the user_id and also recommendation_id I want to edit, and then I’m iterating through all the recommendations for the user comparing against the recommendation_id, which I feel is not the right approach, as the size of the table grows the performance could be impacted.
  3. My question is how do I edit recommendation without passing user_id and just using recommendation_id
  4. My current endpoint looks like /users/{user_id}/recommendations/{id}, however I’m looking for something like /recommendations/{id}.

Appreciate the help. Thank you.