Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwh committed Oct 4, 2023
1 parent 4c04fed commit d4fd4d8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ impl NewId for UserId {
id: inner_id.into(),
})
}

fn get_inner_string(&self) -> String {
self.0.id.to_string()
}
}
```

> NOTE: For most use cases, most of the above code is boilerplate that could be eliminated with a procerdural macro, where the only thing specified is the table name. PRs welcome!
Now you can instantiate the `UserId` type using `new`, and use it in your struct with SurrealDB like so:

```rust
Expand Down Expand Up @@ -60,6 +62,14 @@ let retrieved_user: User = create_result.unwrap().remove(0);
assert_eq!(user_to_be_created, retrieved_user)
```

You also get the following methods on your custom ID type for free:

```rust
typesafe_custom_id.table() // returns "users"
typesafe_custom_id.id_with_brackets() // returns "⟨fa77edc3-56ed-4208-9e0b-c0b1c32e2d34⟩"
typesafe_custom_id.id_without_brackets() // returns "fa77edc3-56ed-4208-9e0b-c0b1c32e2d34"
```

## License

Licensed under either of
Expand Down

0 comments on commit d4fd4d8

Please sign in to comment.