Reputation: 879
I have a situation where i need to find the duplicates and remove them from DynamoDB ,here is the table situation :itemID , CustomerID , "Details".
I want to delete the entire record if a customer has duplicates items from DynamoDB.
Here is the table situation:
In the above table i want to delete the 4th row which has a duplicate record with the row 1.
Upvotes: 0
Views: 595
Reputation: 13731
You didn't say anything else about the needs of your application. If this de-duplication is the only concern, I think the solution is easy - make (CustomerID, ItemID) the item's key. For example, CustomerID can be the hash key, ItemID the sort key. Then, when you update the item with a certain customerid and itemid - it will replace the existing item (if any) with the same key.
Note that my suggestion also means that a (c1, p1, Coffee) will replace an existing (c1, p1, Sugar) - I don't know if this something you wanted or not, as in your example the second mention of the same item also had the same "Details".
Upvotes: 2