SurrealDB Docs Logo

Enter a search query

.Live[T](table, diff)

Initiate a live query from a SurrealQL statement.

Method Syntax
db.Live[UUID](table, diff)

Arguments

ArgumentsDescription
sql required

Specifies the SurrealQL statements.

cancellationToken optional

The cancellationToken enables graceful cancellation of asynchronous operations.

Example usage

package main import ( "fmt" "github.com/surrealdb/surrealdb.go" "github.com/surrealdb/surrealdb.go/pkg/models" ) func main() { // Assuming db is an instance of your database connection table := models.Table("person") diff := true // Whether to receive diffs or not uuid, err := surreal.Live(db, table, diff) if err != nil { fmt.Println("Error initiating live query:", err) return } // Use the UUID for the live query... }