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

Add historical hydrate #16

Open
jeffa5 opened this issue Mar 13, 2023 · 2 comments
Open

Add historical hydrate #16

jeffa5 opened this issue Mar 13, 2023 · 2 comments

Comments

@jeffa5
Copy link

jeffa5 commented Mar 13, 2023

I'm currently wanting to use this for restoring values in a document both at the latest state as well as sometimes from historical versions, using _at queries with the list of heads.

I can't see how to use autosurgeon's hydrate for this but I may be missing something. If it is missing I'd be happy to have a go at implementing it.

@alexjg
Copy link
Collaborator

alexjg commented Mar 13, 2023

One possibility would be to use fork_at to obtain a copy of the document as at the given heads and then hydrate from that.

@orionz is working on a reformulation of the ReadDoc trait which rather than having _at methods on it allows you to just obtain a ReadDoc as at a given set of heads. Once that lands we should be able to update autosurgeon to use that approach so you would be able to do something like:

let mydata: MyData = hydrate(doc.at(&heads))?

@jeffa5
Copy link
Author

jeffa5 commented Mar 13, 2023

Ok, that sounds good. In the meantime I think I should be able to add a wrapper struct myself to use the _at calls when needed.

I think fork_at would be too expensive to be practical for this application but worth noting.

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