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

Dexie cloud: partial updates via REST API #2088

Open
dusty-phillips opened this issue Oct 28, 2024 · 3 comments
Open

Dexie cloud: partial updates via REST API #2088

dusty-phillips opened this issue Oct 28, 2024 · 3 comments

Comments

@dusty-phillips
Copy link
Contributor

Can it be possible to do a "patch" style request to a REST endpoint? The only update mechanism right now appears to be a full upsert, where you have to include all of the object's fields.

This means that to do an update, you need to first GET, and then POST the entire updated value. Because these don't happen atomically, this can create a problematic race condition if the UI pushes other updates to the object between the GET and POST that get obliterated.

(TBH, I'm pretty sure the correct answer here is "Dusty stop abusing the REST endpoints.")

@dfahlander
Copy link
Collaborator

That would probably be an alternative to https://github.com/orgs/dexie/projects/4?pane=issue&itemId=71245732&issue=dexie%7CDexie.js%7C2003 I suppose. Sorry I have been very busy with the YJS support and all smaller FRs have stood back, but now that the YJS support is feature complete and under testing I hope to fix this quite soon. Would a PATCH request eliminate your need for transaction support? I also have another requirement to document the sync end point or enhance it so that it could be used from a node client (https://github.com/orgs/dexie/projects/6?pane=issue&itemId=78506729&issue=dexie%7CDexie.js%7C2065). This would make it possible to to transactions but probably a bit more verbose to use.

@dusty-phillips
Copy link
Contributor Author

I forgot about that. 😂 at least I am consistent.

I don’t think a patch would solve the problem defined in that ticket because it was a multi-table transaction. A transaction would solve the problem in this one, though.

Documenting and using the sync endpoint might be helpful, but I suspect the push/pull nature would be weird since the node service represents multiple users. I don’t want to have to wait to pull the entire db for a user in order to push one change to it. But if I can just somehow inject a patch into it in a safe transaction it’d be cool.

Crazy random thought: what if ssr based frameworks could sync the user’s db seamlessly on client and server? 😵‍💫

@dfahlander
Copy link
Collaborator

Yes, the sync end point would need support for some other use cases than what it's tailored for currently. I'd like to cherry pick the consistency features of it without having to sync entire realms or dbs.

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

No branches or pull requests

2 participants