Giter Site home page Giter Site logo

surrealdb / surrealdb.rs Goto Github PK

View Code? Open in Web Editor NEW
64.0 11.0 7.0 92 KB

SurrealDB driver for Rust

Home Page: https://surrealdb.com

License: Apache License 2.0

database database-connector iot-database realtime-database rust rust-library surreal surrealdb rust-crate

surrealdb.rs's Introduction

The Rust client library is now part of the surrealdb crate and will be available from version 1.0.0-beta.9.

surrealdb.rs

The official SurrealDB library for Rust.

surrealdb.rs's People

Contributors

aelto avatar rushmorem avatar tobiemh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

surrealdb.rs's Issues

Bug: Code freeze on signin for windows

Describe the bug

When my code reaches the signin function it freezes, no response is returned.

Steps to reproduce

Run searreal DB with the following command

surreal start --log debug --user root --pass root memory

Write the following code in main.rs

use surrealdb_rs::param::Root;
use surrealdb_rs::protocol::Ws;
use surrealdb_rs::{Result, Surreal};


#[tokio::main]
async fn main() -> Result<()> {
    println!("sneaky");

    let client = Surreal::connect::<Ws>("localhost:8000").await?;

    println!("going dark");

    client
        .signin(Root {
            username: "root",
            password: "root",
        })
        .await?;

    println!("finish signing in");

    // Select a specific namespace and database
    client.use_ns("test").use_db("test").await?;

    println!("sat DB");

    Ok(())
}

The output from the surrealdb CLI is:

[2023-01-04 19:35:51] INFO  surreal::web 127.0.0.1:59640 GET /rpc HTTP/1.1 101 "-" 679.6µs

The output from cargo run is:

   Compiling users_micservice v0.1.0 (F:\Programming\Rust\users_micservice)
    Finished dev [unoptimized + debuginfo] target(s) in 3.11s
     Running `target\debug\users_micservice.exe`
sneaky
going dark

If I forcibly stopped the CLI server using ctrl+c than the cargo run is also stop

Error: Error { kind: Socket, message: "socket error; receiving on a closed channel" }
error: process didn't exit successfully: `target\debug\users_micservice.exe` (exit code: 1)

My Cargo.toml

[package]
name = "users_micservice"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1", features = ["full"] }
serde = "1.0.152"
serde_json = "1.0.91"
surrealdb-rs = { git = 'https://github.com/surrealdb/surrealdb.rs' }

Expected behaviour

to login normally

SurrealDB version

surreal 1.0.0-beta.8+20220930.c246533 for windows on x86_64

Contact Details

[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Feature: support relate as a method

Is your feature request related to a problem?

in my code, I have some sql example f->t->w.
I want to get relation id or data.

Relation {
    id: thing("identity:1").unwrap(),
    from: thing("mobile:1").unwrap(),
    with: thing("account:1").unwrap(),
}
let create_identity = format!("relate mobile:123->identity->account:hz content {time: 1234}");
db.execute_one::<Relation>(create_identity).await;

by the way, propin can't be in schema(struct)
What do you think of this feature

Describe the solution

execute sql, get relation and data.

  1. define a Method Relate
  2. define DbResource::Relate and impl Resource
  3. handle return value, making it into (relate, data)

Alternative methods

none

SurrealDB version

1.0.0-beta.8

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Bug: dependency for surrealdb

Describe the bug

Surrealdb dependency is mapped to git repository https://github.com/rushmorem/surrealdb, instead to the official crates package registry.

Steps to reproduce

Add this crate dependency to a rust project by running:
cargo add surrealdb-rs --git https://github.com/surrealdb/surrealdb.rs

Expected behaviour

In this Cargo.toml file the dependency should be mapped to crates package registry.

SurrealDB version

This version

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

design questions

After playing around with Surrealdb i started getting a couple of questions on why some things are done the way they are.

  • why does is the sql::Value being used for responses instead of a generic
  • why cant the datastore accept the session instead of having to input it every time

Suggestions

  • turn datastore.execute into a builder so you can specify strict and variables only when needed
  • use a different http library instead of surf (it uses 150 dependencies 🤯 ) or only use surf when in wasm otherwise isahc
  • use generics where possible instead of sql::Value
  • make Response::output not return a reference of the error

Feature: connect to a file based database (eg. for desktop app persistence)

Is your feature request related to a problem?

Accessing a local file based surrealdb (kv-rocksdb) is raw with the surrealdb crate.

Describe the solution

Connect to the file based database through this SDK.

Alternative methods

Implement model controllers from scratch with surrealdb crate and its Datastore#execute.

SurrealDB version

surreal 1.0.0-beta.8+20220930.c246533 for macos on aarch64

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Feature: Duplicate index should set specific kind instead of generic Query ErrorKind

Is your feature request related to a problem?

I have an index that avoid's duplicate username. I would like it to throw specific request so I can handle it.

(Error { kind: Query, message: "failed to perform query; Database index `username_idx` already contains 'admin', with record `user:ce7psl4jqouice6j35ug`" })

Describe the solution

Set kind as DuplicateIndex(username_idx) or some other error code.

Alternative methods

Need to use string contains.

SurrealDB version

Release v1.0.0-beta.8

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.