surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
272 stars 45 forks source link

Fix live query UUID #236

Closed tai-kun closed 3 months ago

tai-kun commented 3 months ago

Thank you for the great work on this project.

What is the motivation?

I was unable to subscribe to record changes using the live method. After researching, I found the following:

What does this change do?

What is your testing strategy?

Add three tests to tests/integration/tests/live.ts:

  1. The test suite "live" checks that the live method returns a UUID class on the WebSocket engine and verifies that live queries work. Also, checks that it fails on the HTTP engine.
  2. The test suite "unsubscribe live" checks whether a subscribed live query can be unsubscribed using the UUID class returned by the live method. As far as the HTTP engine is concerned, it doesn't support this, so we don't test anything.
  3. The test suite "kill" checks whether a subscribed live query can be canceled using the UUID class returned by the live method. As far as the HTTP engine is concerned, it doesn't support this, so we don't test anything.

Is this related to any issues?

N/A

Have you read the Contributing Guidelines?

kearfy commented 3 months ago

Great find @tai-kun, and thank you for adding some tests around live queries! Hadn't found the time to add them myself but this is great 😃