Hey,
I am the developer of the y-mongodb-provider, which is mostly a fork of y-leveldb, and I am currently facing a very special problem. I have a use case where it can happen that I want to write a single update that is bigger than 16MB, which is the maximum allowed document size for MongoDB. In my opinion, there are two ways to reduce this size:
- I can call my MongoDB provider multiple times with smaller updates.
- I can detect these big updates in my provider and split the update there. I would definitely prefer this one; however, I don’t actually know how to split an update.
Lets get you some code context.
This is how I call the provider to write an update:
const persistedYdoc = await mdb.getYDoc(docName);
const persistedStateVector = Y.encodeStateVector(persistedYdoc);
const diff = Y.encodeStateAsUpdate(updatedDoc, persistedStateVector);
await mdb.storeUpdate(docName, diff);
This is the important part of what the provider does in storeUpdate
:
await db.put(createDocumentUpdateKey(docName, clock + 1), { value: buffer.Buffer.from(update) });
Does anyone know how to split document updates?
Thanks for the help!