Live Queries SurrealDB | Rust Language

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 มี.ค. 2024
  • In this video I show examples of live queries in Rust using the SurrealDB database and Rust SDK. The live query stream updates the display as a table, record, or range of records are updated, in real time! In the second half of the video I deserialize the Result with a custom print function.
    🦀 SurrealDB Rust Playlist
    • SurrealDB + Rust Examples
    Relate in SurrealDB:
    ---------------------------------
    surrealdb.com/docs/surrealdb/...
    Record Links:
    ----------------------
    I may cover record links in a future video, but in the meantime here's an article I wrote about them:
    🟩🟥 redandgreen.co.uk/record-link...
    ** New: I've created some slightly more ADVANCED queries and added them to my website, with these you will need to learn and understand "relate" but after a while it starts to feel a bit more intuitive.
    take v first
    -----------------
    .take(0) returns an empty iterator.
    .first() returns an Option containing the first element of the vector or None if the vector is empty.
    More advanced SurrealDB queries
    ----------------------------------------------------------
    🟩🟥 redandgreen.co.uk/surrealdb-c...
    Previous Article:
    ---------------------------
    🟩🟥 redandgreen.co.uk/learn-surre...
    code : gist.github.com/RGGH/d23d14d2...
    install SurrealDB
    ---------------------------
    🟩 surrealdb.com/install
    start the server
    -------------------------
    surreal start --log info --user root --pass root file:mydatabase.db
    Demo Data
    --------------------
    🟩 surrealdb.com/docs/surrealdb/...
    Useful code example using fetch, with query prepared using format! macro:
    -------------------------------------------------------------------------------------------------------------------------
    🟩 github.com/surrealdb/surreald...
    Linux Hosting - VPS server - Webdock
    ----------------------------------------------------------------
    🟩
    Webdock Linux Hosting : webdock.io/en?maff=wdaff--170
    🟩
    Nostr
    ---------
    @RngWeb
    findthatbit@iris.to
    findthatbit.info/
    redandgreen.co.uk/
    #rustlang #SurrealDB #learningrust

ความคิดเห็น • 2

  • @Tszyu01
    @Tszyu01 2 หลายเดือนก่อน +1

    This stream seems to run forever. Which can be great but how would you go about conditionally closing the live stream, let’s say closing the stream once it gets to rating 3.

    • @learning_rust
      @learning_rust  2 หลายเดือนก่อน +1

      That's interesting question, I think there is a way to do it here : surrealdb.com/docs/surrealdb/integration/websocket#kill
      but you need the uuid, so you'd need to get that from a 'result' - "The UUID of the live query to kill" and then end the live query with the scope of the conditional logic that you add, eg "if rating > 3"