Skip to content

Commit

Permalink
Update Rust examples
Browse files Browse the repository at this point in the history
  • Loading branch information
rushmorem committed Sep 17, 2024
1 parent 2f9b018 commit 8331832
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/content/doc-sdk-rust/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async fn main() -> surrealdb::Result<()> {
db.use_ns("test").use_db("test").await?;

// Create a new person with a random id
let created: Vec<Record> = db
let created: Option<Record> = db
.create("person")
.content(Person {
title: "Founder & CEO",
Expand Down Expand Up @@ -227,7 +227,7 @@ Surreal::init()

### Example usage
```rust
static DB: Lazy<Surreal<Client>> = Lazy::new(Surreal::init);
static DB: LazyLock<Surreal<Client>> = LazyLock::new(Surreal::init);

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
Expand Down Expand Up @@ -822,7 +822,7 @@ db.create(resource).content(data)
### Example usage
```rust
// Create a record with a random ID
let people: Vec<Person> = db.create("person").await?;
let person: Option<Person> = db.create("person").await?;
// Create a record with a specific ID
let record: Option<Record> = db
.create(("person", "tobie"))
Expand Down
14 changes: 4 additions & 10 deletions src/content/doc-surrealdb/embedding/rust.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ SurrealDB is designed to be run in many different ways, and environments. Due to

## Install the SDK

First, create a new project using `cargo new` and add the SurrealDB crate to your dependencies:

```sh
cargo add surrealdb
```

You will then need to enable the appropriate features (for a full list see https://crates.io/crates/surrealdb):
First, create a new project using `cargo new` and add the SurrealDB crate to your dependencies, enabling the key-value store you need:

```sh
# For an in memory database
Expand Down Expand Up @@ -100,7 +94,7 @@ async fn main() -> surrealdb::Result<()> {
db.use_ns("test").use_db("test").await?;

// Create a new person with a random id
let created: Vec<Record> = db
let created: Option<Record> = db
.create("person")
.content(Person {
title: "Founder & CEO",
Expand Down Expand Up @@ -234,7 +228,7 @@ Surreal::init()

### Example usage
```rust
static DB: Lazy<Surreal<Client>> = Lazy::new(Surreal::init);
static DB: LazyLock<Surreal<Client>> = LazyLock::new(Surreal::init);

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
Expand Down Expand Up @@ -733,7 +727,7 @@ db.create(resource).content(data)
### Example usage
```rust
// Create a record with a random ID
let people: Vec<Person> = db.create("person").await?;
let person: Option<Person> = db.create("person").await?;
// Create a record with a specific ID
let record: Record = db
.create(("person", "tobie"))
Expand Down

0 comments on commit 8331832

Please sign in to comment.