Could anyone help me to visualize how Yjs works?

@choikangjae More like this:

  • Data is only persisted to a storage medium (red) via providers (blue).
  • Providers replicate data across different Y.Docs. Providers are necessary for all persistence and network transport.

It should be clear from the above diagram that a provider running on the server can store data in a centralized database. Just wire it up as described in the docs and it will happily replicate any updates while it is connected.

const mdb = new MongodbPersistence(createConnectionString("yjstest"), {
	collectionName: "transactions",
	flushSize: 100,
	multipleCollections: true,
});

yUtils.setPersistence({
  ...
})
8 Likes