• Start

Methods

live_query

The live_query() method for the SurrealDB Mojo SDK starts a live query on a table.

Starts a live query on a table and returns the query id as a string. Notifications arrive out of band and are queued by the transport; pull them out with poll_notifications().

Method Syntax
client.live_query(table, session)

Argument

Description

table

The table to subscribe to.

session

An optional session id.

var query_id = client.live_query("person")

var notifications = client.poll_notifications()
for ref in notifications:
    print(ref[].query_id, ref[].action)

To get the full RpcResponse instead of just the query id, use live_raw(table, session).

Note

Live queries run over a stateful WebSocket session. WebSocket support is rolling out. On the HTTP transport, the engine reports live_queries=False and the SDK raises an UnsupportedFeatureError.

Was this page helpful?