Skip to content

Commit 0d4932a

Browse files
committed
Edit
1 parent 74f7d45 commit 0d4932a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

SeaORM/docs/06-relation/02-one-to-many.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,20 @@ impl Related<super::cake::Entity> for Entity {
9393
}
9494
}
9595
```
96-
</details>
96+
</details>
97+
98+
## Composite Foreign Key
99+
100+
Composite foreign key is supported using a tuple syntax.
101+
102+
```rust
103+
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
104+
pub enum Relation {
105+
#[sea_orm(
106+
belongs_to = "super::cake::Entity",
107+
from = "(Column::CakeId, Column::VariantId)",
108+
to = "(super::cake::Column::Id, super::cake::Column::VariantId)",
109+
)]
110+
CakeFilling,
111+
}
112+
```

SeaORM/docs/06-relation/04-complex-relations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ How can we define the `Fruit` Entity?
170170
By default, `has_many` invokes the `Related` trait to define the relation.
171171
As a consequence, it's not possible to define the Relation without `Related` impl.
172172

173-
Here we have to specify the Relation variant of the related entity manually with the `via` attribute.
173+
Here we have to specify the Relation variant of the related entity manually with the `via_rel` attribute.
174174

175175
```rust
176176
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
@@ -183,9 +183,9 @@ pub struct Model {
183183

184184
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
185185
pub enum Relation {
186-
#[sea_orm(has_many = "super::cake::Entity", via = "Relation::Topping")]
186+
#[sea_orm(has_many = "super::cake::Entity", via_rel = "Relation::Topping")]
187187
CakeTopping,
188-
#[sea_orm(has_many = "super::cake::Entity", via = "Relation::Filling")]
188+
#[sea_orm(has_many = "super::cake::Entity", via_rel = "Relation::Filling")]
189189
CakeFilling,
190190
}
191191
```

0 commit comments

Comments
 (0)