mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
doc/md: update doc for OnDelete annotation (#3460)
Signed-off-by: Giau. Tran Minh <hello@giautm.dev>
This commit is contained in:
@@ -49,7 +49,7 @@ func (User) Fields() []ent.Field {
|
|||||||
Ent allows to customize the foreign key creation and provide a [referential action](https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#foreign-key-referential-actions)
|
Ent allows to customize the foreign key creation and provide a [referential action](https://dev.mysql.com/doc/refman/8.0/en/create-table-foreign-keys.html#foreign-key-referential-actions)
|
||||||
for the `ON DELETE` clause:
|
for the `ON DELETE` clause:
|
||||||
|
|
||||||
```go title="ent/schema/user.go"
|
```go title="ent/schema/user.go" {27}
|
||||||
package schema
|
package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -76,9 +76,7 @@ func (User) Fields() []ent.Field {
|
|||||||
func (User) Edges() []ent.Edge {
|
func (User) Edges() []ent.Edge {
|
||||||
return []ent.Edge{
|
return []ent.Edge{
|
||||||
edge.To("posts", Post.Type).
|
edge.To("posts", Post.Type).
|
||||||
Annotations(entsql.Annotation{
|
Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||||
OnDelete: entsql.Cascade,
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user