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

What is expected behavior if I create/delete/create using the same ID? #95

Closed
jessegrosjean opened this issue May 14, 2024 · 1 comment · Fixed by #99
Closed

What is expected behavior if I create/delete/create using the same ID? #95

jessegrosjean opened this issue May 14, 2024 · 1 comment · Fixed by #99
Labels
question Further information is requested

Comments

@jessegrosjean
Copy link
Contributor

Right now this gives me a DuplicateID exception:

repo.create(id, doc)
repo.delete(id)
repo.create(id, doc) // DuplicateID exception

This is because after delete repo.handes still contains an internal document handle. I'm not sure if this is by design or not.

I'm running into this problem when I try to build start sharing/stop sharing commands for my document. The general idea is that when I'm sharing my document it should be in the repo, when I'm not it should not be in the repo. I understand that peers might still have a copy even when not sharing.

@heckj
Copy link
Collaborator

heckj commented May 14, 2024

yeah, it's by design - but not specifically well thought out by me, I was replicating what's in JS automerge-repo. Delete marks the item locally as deleted, with the concept being that others might have replicas and try to continue to sync, and we don't want to just "reload" on sync when we've deleted it.

The (perhaps poor) conceit/conception is that all documents are always in the repo, and you control the sharing by allowing or disallowing it with the sharing controls (either the static .agreeable or something you make that provides a choice of "may I share" given an ID and peerID (conforms to ShareAuthorizing)

That said, I think there should be a way for you to ask to "nuke" this ID so that it doesn't exist, or potentially allow a create() to replace it without hitting that error.

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

Successfully merging a pull request may close this issue.

2 participants