Live database queries over WebSockets
The browser subscribes to a query and gets the result. When the data changes, from any writer, it gets the new result. No polling, no cache invalidation code.
How it works
- Subscribe by name. The browser sends
{"type": "subscribe", "target": "openTasks", "observe": "tasks", "config": {"query": {"status": "open"}}}and receivespayload.openTasks. - The database reports changes. MongoDB change streams, PostgreSQL
LISTEN/NOTIFYtriggers, or an SQLite journal table filled by triggers. All three see writes from any process, not only this server. - Only relevant changes cost a query. Each subscription checks a change against its query and fields before reloading, and collapses bursts of changes.
- Lists, single documents, counts. With paging, sorting, projections, totals, and an incremental mode that sends single documents instead of whole lists.
Two implementations, one protocol
Rust new
owservable-core plus MongoDB, PostgreSQL and SQLite backends, built on tokio. Bring any WebSocket server.
TypeScript v3
@owservable/* on npm, with RxJS stores and mongoose / MikroORM adapters. Developed alongside the Rust crates.
Frontends don't care which one runs the server: both send the same messages, and the Rust side is tested against recordings of the TypeScript one.