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: Blog/blog/2025-10-20-sea-orm-2.0.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ pub enum Relation {
354
354
}
355
355
```
356
356
357
-
This aspect is not different from 1.0. A `Related` impl will not be generated. The relation can be used in joins, but currently not supported by the loader (we do plan to support it soon).
357
+
This aspect is not so different from 1.0. A `Related` impl will not be generated, but the relation can still be used in loader.
Copy file name to clipboardExpand all lines: Blog/blog/2025-10-30-sea-orm-2.0.md
+56-56Lines changed: 56 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ SeaORM used to adopt a schema‑first approach: meaning you design database tabl
25
25
26
26
Entity‑first flips the flow: you hand-write the entity files, and let SeaORM generates the tables and foreign keys for you.
27
27
28
-
All you have to do is to add the following to your `main.rs` right after creating the database connection:
28
+
All you have to do is to add the following to your [`main.rs`](https://github.com/SeaQL/sea-orm/blob/master/examples/quickstart/src/main.rs) right after creating the database connection:
29
29
30
30
```rust
31
31
letdb=&Database::connect(db_url).await?;
@@ -37,7 +37,9 @@ This requires two feature flags `schema-sync` and `entity-registry`, and we're g
37
37
38
38
## Unfolding
39
39
40
-
The above function `get_schema_registry` desugars into the following:
40
+
### Entity Registry
41
+
42
+
The above function `get_schema_registry` unfolds into the following:
41
43
42
44
```rust
43
45
db.get_schema_builder()
@@ -53,7 +55,7 @@ You might be wondering: how can SeaORM recognize my entities when, at compile ti
53
55
54
56
Rest assured, there's no source‑file scanning or other hacks involved - this is powered by the brilliant [`inventory`](https://docs.rs/inventory/latest/inventory/) crate. The `inventory` crate works by registering items (called plugins) into linker-collected sections.
55
57
56
-
At compile-time, each `Entity` module registers itself to the global `inventory` along with their module paths and some metadata. On runtime, SeaORM then filters the Entities you requested and construct a `SchemaBuilder`.
58
+
At compile-time, each `Entity` module registers itself to the global `inventory` along with their module paths and some metadata. On runtime, SeaORM then filters the Entities you requested and construct a [`SchemaBuilder`](https://docs.rs/sea-orm/2.0.0-rc.15/sea_orm/schema/struct.SchemaBuilder.html).
57
59
58
60
The `EntityRegistry` is completely optional and just adds extra convenience, it's perfectly fine for you to `register` Entities manually like above.
59
61
@@ -73,13 +75,14 @@ Let's walk through the different scenarios:
73
75
74
76
Let's say you added a new Entity under `mod.rs`
75
77
76
-
```rust
78
+
```rust title="entity/mod.rs"
77
79
//! `SeaORM` Entity, @generated by sea-orm-codegen 2.0.0-rc.14
78
80
79
81
pubmodprelude;
80
82
81
83
pubmodpost;
82
84
pubmodupvote; // ⬅ new entity module
85
+
..
83
86
```
84
87
85
88
The next time you `cargo run`, you'll see the following:
@@ -92,22 +95,21 @@ This will create the table along with any foreign keys.
@@ -221,7 +221,7 @@ The next time you `cargo run`, you'll see the following:
221
221
CREATE UNIQUE INDEX "idx-user-name" ON "user" ("name")
222
222
```
223
223
224
-
As mentioned in the previous blog post, you'll also get a shorthand method generated on the Entity for free:
224
+
As mentioned in the previous blog post, you'll also get a shorthand method generated on the Entity:
225
225
226
226
```rust
227
227
user::Entity::find_by_name("Bob")..
@@ -253,11 +253,11 @@ DROP INDEX "idx-user-name"
253
253
254
254
Note that in general schema sync would not attempt to do any destructive actions, so meaning no `DROP` on tables, columns and foreign keys. Dropping index is an exception here.
255
255
256
-
Every time the application starts, a full schema discovery is performed. It's not recommended to enable this in production, and so this is gated behind a feature flag `schema-sync` that can be turned off based on build profile.
256
+
Every time the application starts, a full schema discovery is performed. This may not be desirable in production, so `sync` is gated behind a feature flag `schema-sync` that can be turned off based on build profile.
257
257
258
258
## 🧭 Instant GraphQL API
259
259
260
-
With [Seaography](https://github.com/SeaQL/seaography), the Entities you wrote can instantly be exposed as a GraphQL schema, with full CRUD, filtering and pagination. The GraphQL data loader is actually more powerful, as it allows nesting relations with arbitrary complexity.
260
+
With [Seaography](https://github.com/SeaQL/seaography), the Entities you wrote can *instantly* be exposed as a GraphQL schema, with full CRUD, filtering and pagination. No extra macros, no Entity re-generation is needed!
261
261
262
262
With SeaORM and Seaography, you can prototype quickly and stay in the flow. And because Seaography is highly customizable, you can gradually shift resolver logic into your own implementation as the application evolves, and layer access control on top before the project goes to production.
0 commit comments