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

Fix update/updateOrCreate in cloudant.js #35

Closed
jannyHou opened this issue Sep 27, 2016 · 4 comments
Closed

Fix update/updateOrCreate in cloudant.js #35

jannyHou opened this issue Sep 27, 2016 · 4 comments
Labels

Comments

@jannyHou
Copy link
Contributor

jannyHou commented Sep 27, 2016

Use updateAttributes function to update a model instance and use update function in call for updateOrCreate.

Currently, update performs a destructive update. With this change update function should be partial update.

@jannyHou jannyHou self-assigned this Sep 27, 2016
@jannyHou jannyHou added the bug label Sep 27, 2016
@djorg83
Copy link

djorg83 commented Apr 27, 2017

Possibly related to #110

@jannyHou
Copy link
Contributor Author

@djorg83 thanks for catching the error in #110 , this is not the same one.
cloudant only support full replace of document, but not partial update.
This issue will implement an update method which does partial update.

@jannyHou
Copy link
Contributor Author

jannyHou commented May 4, 2017

Some possible solutions:

  • Keep it same as replaceOrCreate, and warn users there is not partial update.
  • (Tricky) We implement a way to merge data from document and updated data, then call _insert , which will do replace
  • Throw error/warning in this method to explicitly tell user they need to define their own method if they do want to partial update.

@cwadding
Copy link

cwadding commented Feb 4, 2020

@jannyHou one solution for a partial update are to use update handlers https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-design-documents#update-handlers
This would need to be enabled on the cloudant database but can make it so that the updates are not a destructive operation.
It might would be nice to be able to specify the desired update handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants