y-op-sqlite
v1.0.7
Published
<p align="center"> <img src="https://cdn.malts.me/6Wu0Fj.svg" /> </p>
Maintainers
Readme
About
y-op-sqlite is a persistence provider for Yjs that uses op-sqlite to store document changes in a SQLite database. This is useful for React Native projects that need to access YJS documents without an internet connection to enable a local-first experience.
Installing
You can install y-op-sqlite and its peer dependencies using expo:
# install using expo
npx expo install y-op-sqlite yjs @op-engineering/op-sqliteOr alternatively using npm:
# install using npm
npm i y-op-sqlite yjs @op-engineering/op-sqliteMake sure to check the op-sqlite docs for instructions on setting up op-sqlite in your React Native project.
Usage
import { OPSQLitePersistence } from 'y-op-sqlite';
// other code...
const provider = new OPSQLitePersistence(docName, ydoc);
provider.whenSynced.then(() => {
console.log("content finished loading from database.");
});When you're done accessing the document, you can destroy the connection to the provider:
// stop syncing with database
provider.destroy();Attribution
This library is based on y-indexdb by Kevin Jahns. Thanks to @ospfranco for creating op-sqlite.
