Live Queries
@kalamdb/client supports realtime subscriptions via WebSocket.
The client has exactly three realtime entry points:
live(sql, onRows, options?)for materialized rows from any supportedSELECT.liveTable(tableName, onRows, options?)for materialized rows fromSELECT * FROM table.liveEvents(sql, onEvent, options?)for low-level protocol events.
Which Mode Should I Choose?
| Mode | Start with | Best for | You manage |
|---|---|---|---|
simple | live() or liveTable() | UI state, feeds, timelines, dashboards, chat windows | almost nothing; the SDK materializes the row set for you |
advanced | liveEvents() | custom event handling and protocol-aware realtime logic | raw events, change_type, rows, old_values, and batch metadata |
Use simple when you want the latest rows.
Use advanced when you want to own the subscription lifecycle and event handling.
Simple Mode
- Read: Simple Realtime Mode
- Start with
live()orliveTable(). - The SDK reconciles inserts, updates, and deletes into one current row set.
Advanced Mode
- Read: Advanced Realtime Mode
- Start with
liveEvents()for raw events. - This mode exposes
change_type,rows,old_values,_seq,subscription_id, andbatch_controldirectly.
Shared Subscription Rules
- Live SQL must stay within the strict supported shape:
SELECT ... FROM ... WHERE .... - Do not include
ORDER BYorLIMITinsidelive()orliveEvents()SQL. batchSizechunks the initial snapshot coming from the server.lastRowscontrols how much history to rewind before live changes begin.fromresumes from a knownSeqIdcheckpoint.limitapplies only to the high-level materialized row set thatlive()keeps after startup.
Next Reads
Last updated on