How to to persist share types?

On my Yjs client-server communication, I’m able to store the data server-side by invoking encodeStateAsUpdate.

But I’m not able to save the JSON representation of the YDoc: the share field is empty as all the updates are pending.

I don’t want to impose any scheme/naming convention, so whatever YDoc text/array/map… name is used on the client is not reflected in a simmetric getText/getArray call on the server; and since I don’t know the shared data type names, I’m not able to invoke any of the toJSON() methods, in order to store a textual representation of the document.

Is there a way to enforce the automatic creation of shared types?

1 Like

You could send your version of the schema with Yjs’ update format. Then the server know exactly how to convert the Yjs document to a JSON document (or whatever you use to store content).

1 Like