https://github.com/maxpert/sqlite-y-crdt
Y-CRDT extension for SQLite
https://github.com/maxpert/sqlite-y-crdt
Last synced: 8 months ago
JSON representation
Y-CRDT extension for SQLite
- Host: GitHub
- URL: https://github.com/maxpert/sqlite-y-crdt
- Owner: maxpert
- License: mit
- Created: 2022-12-21T18:53:03.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-30T19:54:37.000Z (over 2 years ago)
- Last Synced: 2025-05-02T18:53:20.448Z (about 1 year ago)
- Language: Rust
- Size: 42 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQLite Y-CRDTs Extension
This repo is WIP for wrapping Y-CRDT for SQLite.
## Why?
[Yjs](https://yjs.dev/) provides a great way to implement CRDTs. This repository is exploratory PoC of building blocks
that takes the implementation from [Y-CRDT](https://github.com/y-crdt/y-crdt), and exposes them for usage inside
SQLite as functions and operators (just like JSON). This will let developers build:
- Inplace document creation, merging, and modification.
- Identify useful set of operations required for comprehensive usage of Y-CRDTs.
## Usage
Build:
```bash
cargo build
```
Once built load and use in sqlite3 by:
```
sqlite3
.load target/debug/libsqlite_y_crdt.dylib
select ydoc_merge_update(ydoc(1), ydoc(1), 1);
```
## Functions
- `ydoc(version)`: creates an empty YDOC with and serializes it to given `version` as BLOB
- `ydoc_merge_update(target, source, version)`: Decodes and merges updates from `source` into `target`. Encoding
and decoding version is passed as `version` parameter.
- `ydoc_client_id([id])`: Everytime creating a document the passed `id` will be used as document ID. Calling this
function without parameters returns current ID. It's initialized as random value when extension is loaded.