-
Notifications
You must be signed in to change notification settings - Fork 0
/
person_address.go
56 lines (50 loc) · 1.13 KB
/
person_address.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
)
// PersonAddress holds the schema definition for the PersonAddress entity.
type PersonAddress struct {
ent.Schema
}
// Annotations of the PersonAddress.
func (PersonAddress) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "person_addresses"},
field.ID("person_id", "address_id"),
}
}
// Fields of the PersonAddress.
func (PersonAddress) Fields() []ent.Field {
return []ent.Field{
field.UUID("person_id", uuid.UUID{}).
Immutable(),
field.UUID("address_id", uuid.UUID{}).
Immutable(),
}
}
// Edges of the PersonAddress.
func (PersonAddress) Edges() []ent.Edge {
return []ent.Edge{
edge.To("persons", Person.Type).
Field("person_id").
Unique().
Required().
Immutable(),
edge.To("addresses", Address.Type).
Field("address_id").
Unique().
Required().
Immutable(),
}
}
// Mixin of the PersonAddress.
func (PersonAddress) Mixin() []ent.Mixin {
return []ent.Mixin{
TimeMixin{},
}
}