electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
8.07k stars 154 forks source link

Documentation regarding Consistency #323

Open ackava opened 5 days ago

ackava commented 5 days ago

Can you please add some documentation about how to maintain consistency in terms of running it from browser?

  1. Can multiple PGLite easily access single storage (IndexedDB)?
  2. Will it corrupt the data? Do we need any external locking mechanism?
samwillis commented 5 days ago

Good idea, we should document this better.

For quick context, PGlite is Postgres in "single user mode". There is no support for concurrent connections and you are like to corrupt the database if you open it multiple times at once.

The PGliteWorker helps you to open only a single instance and share it across browser tabs.