I have a data model that consist in three models Profile, Company, Profession. Profile is a model that I am using in order to link a Cognito user with structured data (such as Company and Profession). Profile has a many-to-many relation with Company and Profession.
When we go to towards the AWS documentation it is clear that we need to create models and then create a new record on the join table amplify generates when we talk about many-to-many relations.
Nonetheless, the link above doesn't provide information to delete or update many-to-many relations. I assume that in order to update I need to delete the entry on the Join table and then add the new entries (so I avoid duplicated entries and make the job done)
But when I try to delete an entry from the join table I receive the following error:
Error of type "ConditionalCheckFailedException"
Going into the glossary of errors on DynamoDB I don't see which condition I may be created from my side unintended as the error suggest my condition is failing
In summary, in order to allow users to manipulate the professions on their profiles, I am trying to:
- Add a new entry to the
ProfileProfession
table, and it works
But when I try to update by:
- Delete previous entries -> This fails with the error above
- Add new entries -> This works
In case of more context needed here a snippet of the important code I have: https://gist.github.com/duranmla/a8caf14f61ba25fd30610cdb470ee58f
Perhaps my code is not great but I just want to understand how this things work before move further. Thanks in advance to everyone for taking the time to read. ❤️