7

The SurrealDB GitHub readme file states the following: "SurrealDB keeps every client device in-sync with data modifications pushed in realtime to the clients, applications, end-user devices, and server-side libraries".

Although I didn't find any clues in the documentation on how to subscribe to the data modifications or table changes when the WebSocket connection is established.

Is this feature already implemented or is it planned for future releases?

iloginow
  • 133
  • 1
  • 7
  • 3
    Same here, no details about how to subscribe to events. It seems that is not implemented, and GraphQL subscriptions are promised to enable sync data modifications. Otherwise, you're bound to send webhooks using table events, and use an app like soketi to propagate the changes. I also tried to find something in the source code to no avail. This was the only thing I found: https://discord.com/channels/902568124350599239/1014970862031609877/1024451281563168810 – DarkGhostHunter Sep 30 '22 at 07:10

1 Answers1

8

Subscribing to events currently isn't implemented yet, but according to Tobie in discord:

  1. You run a query like the following.. LIVE SELECT * FROM person WHERE age > 18;

  2. This returns a UUID (which is the id of the live query).

  3. Every time that a record is updated that matches the live query, the server sends a CREATE, UPDATE, or DELETE RPC notification...

    1. If CREATE then it will have the new record data.
    2. If UPDATE then it will have the updated record data.
    3. If DELETE then it will have the deleted record ID.
  4. You will also be able to send the following query... LIVE SELECT DIFF FROM person WHERE age > 18;

  5. This will send only the DIFF changes when records are CREATEd, UPDATEd and DELETEd.

  6. To stop listening to the live query you would send... KILL "30eaa4fb-3fc7-45d6-baa0-cb79121ffcc4";

LeoDog896
  • 3,472
  • 1
  • 15
  • 40