I’d like to retrieve the current state of a y-websocket/y-leveldb persisted document, and then create a new document with just the “latest state” (truncating/ignoring all history).
I’m using a custom server that combines HTTP and WS, which allows me to accept an HTTP POST to trigger the action.
I thought I might be able to copy latest state with direct access to the docs map; however, it looks like this map only contains documents stored in memory, so I can’t use it to retrieve a document unless it has already been “vivified” from its persistent store.
Furthermore, this map contains only the
AbstractType type, not the concrete types (e.g. YMap, etc.). So, even if I did have access to all vivified documents, I would not be able to call
toJSON() on any particular one to get its current state. (Calling
AbstractType simply returns
What’s the best approach to retrieving and storing an arbitrary document in
- I’d prefer not to duplicate storage by using a database (but I will if I have to)
- I can’t open the leveldb database directly, because its rules require that only one process has access to its on-disk store at a time