bluzi / jsonstore

:rocket: jsonstore offers a free and secured JSON-based cloud datastore for small projects | Inactive
https://www.jsonstore.io/
MIT License
2.03k stars 75 forks source link

Support for filter with PUT (to avoid write conflicts) #38

Open karmakaze opened 6 years ago

karmakaze commented 6 years ago

If the JSON contains a version field, then it would be possible to prevent accidental overwrites by having each writer pass in the version it's updating. The first would succeed and the second would get an status indicating that the write failed due to the 'optimistic version lock', at which point the operation would be retried by first re-reading the current version.

Another approach which could be better in some cases is support for PATCH where incremental addition/update/delete could be made to a document.

karmakaze commented 6 years ago

Found that mixing short and long paths effectively PATCH the document of the main hash. This wasn't obvious from the README if not already familiar with Firebase. The filtered PUT is still good to have.