Skip to content

Commit

Permalink
Update the Rust setup page
Browse files Browse the repository at this point in the history
  • Loading branch information
rushmorem authored Oct 9, 2024
1 parent 802f8ba commit 0cb576c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/content/doc-sdk-rust/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ Now that we have the basics down, it is time to try out some other methods like
use serde::{Deserialize, Serialize};
use surrealdb::engine::remote::ws::Ws;
use surrealdb::opt::auth::Root;
use surrealdb::sql::Thing;
use surrealdb::RecordId;
use surrealdb::Surreal;
use surrealdb::Value;

#[derive(Debug, Serialize)]
struct Name<'a> {
Expand All @@ -175,7 +176,7 @@ struct Responsibility {

#[derive(Debug, Deserialize)]
struct Record {
id: Thing,
id: RecordId,
}

#[tokio::main]
Expand All @@ -201,7 +202,7 @@ async fn main() -> surrealdb::Result<()> {
},
marketing: true,
})
.await?;
.await?;
dbg!(created);

// Update a person record with a specific id
Expand Down Expand Up @@ -236,12 +237,13 @@ A static singleton can be used to ensure that a single database instance is avai
use serde::{Deserialize, Serialize};
use std::sync::LazyLock;
use surrealdb::engine::remote::ws::{Client, Ws};
use surrealdb::sql::Thing;
use surrealdb::opt::auth::Root;
use surrealdb::RecordId;
use surrealdb::Surreal;

#[derive(Debug, Deserialize)]
struct Record {
id: Thing,
id: RecordId,
}

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -269,6 +271,12 @@ async fn upsert_tobie() -> surrealdb::Result<()> {
async fn main() -> surrealdb::Result<()> {
// Connect to the database
DB.connect::<Ws>("localhost:8000").await?;
// Sign in to the server
DB.signin(Root {
username: "root",
password: "root",
})
.await?;
// Select a namespace + database
DB.use_ns("test").use_db("test").await?;
upsert_tobie().await?;
Expand Down

0 comments on commit 0cb576c

Please sign in to comment.