Custom guid for Y.Doc

Hi. I saw someone pass a custom guid value to new Y.Doc() recently. It got me curious and I couldn’t find much in the code or docs about this. When does it make sense to pass a custom guid / what difference does it make?

Guid is the identifier used by ydoc to isolate content. When we persist the contents of multiple ydocs (such as levelDB), we can read the contents of a specific ydoc through the guid. Similarly, broadcast isolation can also be easily realized through guid in the transmission protocol.

Thanks for the response. I’m still not clear though on when I (as the consumer) should specify a custom guid (if ever)?

I also took a look through the y-leveldb, but couldn’t find any reference to guid being used.

@4degrees My understanding is that if you pass the guid of an existing Doc to a new Doc, they will automatically be synced.

There are some notes about setting a custom guid at the end of the Subdocuments documentation:

1 Like

Ah, got it now thank you. That link really helped - I don’t use subdocuments yet so hadn’t looked there :slight_smile: