SurrealDB Docs Logo

Enter a search query

.LiveNotifications<T>(queryUuid)

Listen responses from an existing live query.

Method Syntax
db.LiveNotifications[UUID string](queryUuid)

Arguments

ArgumentsDescription
queryUuid required

The UUID of the live query to consume.

Example usage

Example
package main package main import ( "fmt" "os" "os/signal" "syscall" ) // Assume db is your database connection with a LiveNotifications method. func main() { // Assuming queryUuid is obtained from a previous Live() call. queryUuid := "your-query-uuid-here" notifications, err := db.LiveNotifications(queryUuid) if err != nil { fmt.Println("Error setting up notifications:", err) return } // Listen for notifications in a goroutine. go func() { for notification := range notifications { // Process each notification as it arrives. fmt.Printf("Received notification: %+v\n", notification) } }() // Wait for a ctrl-C (SIGINT) or termination signal (SIGTERM) before exiting. sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) <-sigs fmt.Println("Exiting...") }