You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SeaORM/docs/01-introduction/03-sea-orm.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,10 @@ Each table corresponds to an [`Entity`](04-generate-entity/02-entity-format.md#e
6
6
7
7
The `Entity` trait provides an API for you to inspect its properties ([`Column`](04-generate-entity/02-entity-format.md#column), [`Relation`](04-generate-entity/02-entity-format.md#relation) and [`PrimaryKey`](04-generate-entity/02-entity-format.md#primary-key)) at runtime.
8
8
9
-
Each table has multiple columns, which are referred to as `attribute`.
9
+
Each table has multiple columns, which are referred to as field.
10
10
11
-
These attributes and their values are grouped in a Rust struct (a [`Model`](12-internal-design/05-expanded-entity-format.md#model)) so that you can manipulate them.
11
+
These fields and their values are grouped in a Rust struct (a [`Model`](12-internal-design/05-expanded-entity-format.md#model)) so that you can manipulate them.
12
12
13
-
However, `Model` is for read operations only. To perform insert, update, or delete, you need to use [`ActiveModel`](12-internal-design/05-expanded-entity-format.md#active-model) which attaches meta-data on each attribute.
13
+
However, `Model` is for read operations only. To perform insert, update, or delete, you need to use [`ActiveModel`](12-internal-design/05-expanded-entity-format.md#active-model) which attaches a state on each field.
14
14
15
-
Finally, there is no singleton (global context) in SeaORM. Application code is responsible for managing the ownership of the `DatabaseConnection`. We do provide integration examples for web frameworks including [Rocket](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example), [Actix](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example), [axum](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example) and [poem](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example) to help you get started quickly.
15
+
Finally, there is no singleton (global context) in SeaORM. Application code is responsible for managing the ownership of the `DatabaseConnection`. We do provide integration examples for web frameworks including [Actix](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example), [axum](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example) and [poem](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example), [Loco](https://github.com/SeaQL/sea-orm/tree/master/examples/loco_example) to help you get started quickly.
Copy file name to clipboardExpand all lines: SeaORM/docs/01-introduction/04-tutorial.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,20 @@ If you prefer a step-by-step tutorial on how to use SeaORM, you can check out ou
4
4
5
5
You can also check out [SeaORM Cookbook](https://www.sea-ql.org/sea-orm-cookbook/) for some frequently asked questions and recommended practices of using SeaORM.
6
6
7
-
If you are so eager and want something grab-and-go, SeaQL maintains a set of official examples contributed by the community (we welcome more!):
7
+
If you are so eager and want something grab-and-go, SeaQL maintains a set of official examples (we welcome more!):
+[Seaography Example (Bakery)](https://github.com/SeaQL/sea-orm/tree/master/examples/seaography_example) / [Seaography Example (Sakila)](https://github.com/SeaQL/seaography/tree/main/examples/sqlite)
21
+
22
+
If you want a simple, clean example that fits in a single file that demonstrates the best of SeaORM, you can try:
Copy file name to clipboardExpand all lines: SeaORM/docs/02-install-and-config/03-debug-log.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# Debug Log
2
2
3
+
## Statement Logging
4
+
3
5
SeaORM logs debug messages via the [`tracing`](https://crates.io/crates/tracing) crate.
4
6
5
7
You can enable SeaORM's logging with the `debug-print` feature flag:
@@ -23,17 +25,25 @@ pub async fn main() {
23
25
}
24
26
```
25
27
26
-
SeaORM's debug print injects parameters into the SQL string, which makes it easier to read. Instead of seeing `SELECT "chef"."name" FROM "chef" WHERE "chef"."id" = $1`, you will see `SELECT "chef"."name" FROM "chef" WHERE "chef"."id" = 100`.
28
+
SeaORM's debug print injects parameters into the SQL string, which makes it easier to read. Instead of seeing:
29
+
30
+
```sql
31
+
SELECT"cake"."name"FROM"cake"WHERE"cake"."id"= $1
32
+
```
33
+
34
+
you will see:
35
+
36
+
```sql
37
+
SELECT"cake"."name"FROM"cake"WHERE"cake"."id"=101
38
+
```
27
39
28
40
## SQLx Logging
29
41
30
42
SQLx also logs by default. If you turned on SeaORM's `debug-print`, you can disable SQLx's log by passing [`ConnectOptions`](https://docs.rs/sea-orm/*/sea_orm/struct.ConnectOptions.html) to `connect()`.
Copy file name to clipboardExpand all lines: SeaORM/docs/03-migration/01-setting-up-migration.md
+9-44Lines changed: 9 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,24 +75,22 @@ Note that if you setup the migration directory directly within a Git repository,
75
75
76
76
## Workspace Structure
77
77
78
-
It is recommended to structure your cargo workspace as follows to share SeaORM entities between the app crate and the migration crate. Checkout the [integration examples](https://github.com/SeaQL/sea-orm/tree/master/examples) for demonstration.
78
+
It is recommended to structure your project as a cargo workspace to separate the app crate and the migration crate. Checkout the [integration examples](https://github.com/SeaQL/sea-orm/tree/master/examples) for demonstration.
79
79
80
80
### Migration Crate
81
81
82
82
Import the [`sea-orm-migration`](https://crates.io/crates/sea-orm-migration) and [`async-std`](https://crates.io/crates/async-std) crate.
83
83
84
84
```toml title="migration/Cargo.toml"
85
85
[dependencies]
86
-
async-std = { version = "1", features = ["attributes", "tokio1"] }
86
+
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
87
87
88
88
[dependencies.sea-orm-migration]
89
-
version = "2.0.0-rc"
89
+
version = "~2.0.0-rc"# sea-orm-migration version
90
90
features = [
91
-
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
92
-
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
# Enable following runtime and db backend features if you want to run migration via CLI
92
+
# "runtime-tokio-native-tls",
93
+
# "sqlx-postgres",
96
94
]
97
95
```
98
96
@@ -118,53 +116,20 @@ impl MigrationTrait for Migration {
118
116
}
119
117
```
120
118
121
-
### Entity Crate
122
-
123
-
Create an entity crate in your root workspace.
124
-
125
-
<details>
126
-
<summary>You don't have SeaORM entities defined?</summary>
127
-
128
-
You can create an entity crate without any entity files. Then, write the migration and run it to create tables in the database. Finally, [generate SeaORM entities](04-generate-entity/01-sea-orm-cli.md) with `sea-orm-cli` and output the entity files to `entity/src/entities` folder.
129
-
130
-
After generating the entity files, you can re-export the generated entities by adding following lines in `entity/src/lib.rs`:
131
-
132
-
```rust
133
-
modentities;
134
-
pubuseentities::*;
135
-
```
136
-
</details>
137
-
138
-
```
139
-
entity
140
-
βββ Cargo.toml # Include SeaORM dependency
141
-
βββ src
142
-
βββ lib.rs # Re-export SeaORM and entities
143
-
βββ post.rs # Define the `post` entity
144
-
```
145
-
146
-
Specify SeaORM dependency.
147
-
148
-
```toml title="entity/Cargo.toml"
149
-
[dependencies]
150
-
sea-orm = { version = "2.0.0-rc" }
151
-
```
152
-
153
119
### App Crate
154
120
155
-
This is where the application logic goes.
121
+
This is where the application logic belongs.
156
122
157
123
Create a workspace that contains app, entity and migration crates and import the entity crate into the app crate.
158
124
159
125
If we want to bundle the migration utility as part of your app, you'd also want to import the migration crate.
160
126
161
127
```toml title="./Cargo.toml"
162
128
[workspace]
163
-
members = [".", "entity", "migration"]
129
+
members = [".", "migration"]
164
130
165
131
[dependencies]
166
-
entity = { path = "entity" }
167
-
migration = { path = "migration" } # depends on your needs
132
+
migration = { path = "migration" }
168
133
169
134
[dependencies]
170
135
sea-orm = { version = "2.0.0-rc", features = [..] }
0 commit comments