blocksuite icon indicating copy to clipboard operation
blocksuite copied to clipboard

> You can try the snapshot API: https://blocksuite.io/guide/data-synchronization.html#snapshot-api

Open undefined-unknown opened this issue 9 months ago • 0 comments

You can try the snapshot API: https://blocksuite.io/guide/data-synchronization.html#snapshot-api

Thanks for the answer! One problem here is that I am doing const json = await job.docToSnapshot(doc); to store json in sql. I will do it again the next time I retrieve it.

const schema = new Schema().register(AffineSchemas);
const collection = new DocCollection({ schema });
const job = new Job({ collection });
const doc = await job.snapshotToDoc(docSnapshot);
doc.load();

Such an operation is not allowed because doc.meta.tags is not in the new collection instance. In this case, should I store it twice? That is

const collectionSnapshot = await job.collectionInfoToSnapshot();

Do it first the next time you use it

const schema = new Schema().register(AffineSchemas);
const collection = new DocCollection({ schema });
const job = new Job({ collection });
job.snapshotToCollectionInfo(_collectionSnapshot);
const doc = await job.snapshotToDoc(docSnapshot);
doc.load();

Originally posted by @undefined-unknown in https://github.com/toeverything/blocksuite/issues/6911#issuecomment-2081999965

undefined-unknown avatar Apr 29 '24 06:04 undefined-unknown