Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating requires the item already exists #50

Closed
wants to merge 2 commits into from
Closed

Updating requires the item already exists #50

wants to merge 2 commits into from

Conversation

jkav77
Copy link
Collaborator

@jkav77 jkav77 commented Dec 21, 2016

No description provided.

@coveralls
Copy link

coveralls commented Dec 21, 2016

Coverage Status

Coverage increased (+0.003%) to 98.636% when pulling eca677a on dangerginger:update-require-exists into cd503bd on clarkie:master.

@jkav77
Copy link
Collaborator Author

jkav77 commented Dec 22, 2016

fixes #51

@coveralls
Copy link

coveralls commented Dec 22, 2016

Coverage Status

Coverage increased (+0.003%) to 98.636% when pulling 3c7d31d on dangerginger:update-require-exists into cd503bd on clarkie:master.

@clarkie
Copy link
Owner

clarkie commented Dec 23, 2016

@dangerginger thanks for all your input recently. I'm concerned as how this and #52 will work when using both hash and range keys.
Also, I can't find it in the docs but does adding these constraints use any extra RCU or WCU?

@deedw
Copy link

deedw commented Dec 23, 2016

I think that this change would break code that relies on current functionality and departs from the expected functionality of the underlying DynamoDb calls.

I use .update() when I want to create or update an item using the fields I am providing without losing any existing field values that the database is already storing - effectively an upsert. When I don't want to create an item if it doesn't already exist then I add a conditional.

I use .create() when I know that I want to create (or overwrite) an item with the specific fields I am providing. I use conditionals when I don't want to overwrite an item.

The proposed approach relies on the opposite logic to this and would require multiple calls to the database to achieve the same outcome.

The underlying DynamoDb call is .updateItem() whose functionality is defined as "Edits an existing item's attributes, or adds a new item to the table if it does not already exist."

If there is a change to be made to .update() I would recommend that it should be addition of an optional property to the params to indicate that item should already exist when updating. The default should be existing functionality.

Apologies if I have misunderstood this change.

@jkav77
Copy link
Collaborator Author

jkav77 commented Dec 24, 2016

@deedw agreed.

See #53 for a better non-breaking solution to this issue

@jkav77 jkav77 closed this Dec 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants