Skip to content

Commit 6d28d55

Browse files
committed
chore: remove redundasnt doc
1 parent 7c72453 commit 6d28d55

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

guide/src/usage/tonbo.md

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,5 @@
11
# Tonbo API
22

3-
<!-- toc -->
4-
5-
## Schema
6-
7-
Tonbo provides ORM-like macro for ease of use, you can use `Record` macro to define schema of column family. Tonbo will generate all relevant code for you at compile time. For example, if you have a struct below
8-
9-
```rust
10-
use tonbo::Record;
11-
12-
#[derive(Record, Debug)]
13-
pub struct User {
14-
#[record(primary_key)]
15-
name: String,
16-
email: Option<String>,
17-
age: u8,
18-
}
19-
```
20-
21-
tonbo will generate a struct `UserSchema` where you can get schema from. Other than `UserSchema`, tonbo will also generate a `UserRef` struct. You should notice that the records you get from tonbo are `UserRef` and all fields except primary key are `Option`.
22-
23-
```rust
24-
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
25-
pub struct UserRef<'r> {
26-
pub name: &'r str,
27-
pub email: Option<&'r str>,
28-
pub age: Option<u8>,
29-
}
30-
```
31-
32-
33-
## Operations
34-
### Create Database
35-
36-
You can use `DB::new(DbOption, Schema)` to create a database. `DbOption` is the configuration options for the database and `Schema` is the `xxxSchema` that tonbo generated.
37-
38-
39-
> **Note:** If you use tonbo in WASM, you should use `Path::from_opfs_path` rather than `Path::from_filesystem_path`.
40-
>
41-
```rust
42-
use std::fs;
43-
use fusio::path::Path;
44-
use tonbo::{executor::tokio::TokioExecutor, DbOption, DB};
45-
46-
#[tokio::main]
47-
async fn main() {
48-
// make sure the path exists
49-
fs::create_dir_all("./db_path/users").unwrap();
50-
51-
let options = DbOption::new(
52-
Path::from_filesystem_path("./db_path/users").unwrap(),
53-
&UserSchema,
54-
);
55-
let db = DB::<User, TokioExecutor>::new(options, TokioExecutor::current(), UserSchema)
56-
.await
57-
.unwrap();
58-
}
59-
```
60-
613
#### DbOption
624
`DbOption` is a struct that contains configuration options for the database. Here are some configuration options you can set:
635

0 commit comments

Comments
 (0)