-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_info.go
68 lines (61 loc) · 1.29 KB
/
product_info.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
57
58
59
60
61
62
63
64
65
66
67
68
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/thaiha1607/foursquare_server/ent/hook"
)
// ProductInfo holds the schema definition for the ProductInfo entity.
type ProductInfo struct {
ent.Schema
}
// Annotations of the ProductInfo.
func (ProductInfo) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "product_info"},
}
}
// Fields of the ProductInfo.
func (ProductInfo) Fields() []ent.Field {
return []ent.Field{
field.String("id").
NotEmpty().
Unique().
MinLen(6),
field.String("name").
NotEmpty(),
field.String("description").
Optional().
Nillable().
Default(""),
field.Int("year").
Optional().
Nillable().
Positive().
Min(1900),
field.String("provider").
Optional().
Nillable(),
}
}
// Edges of the ProductInfo.
func (ProductInfo) Edges() []ent.Edge {
return []ent.Edge{
edge.To("tags", Tag.Type).
Through("product_tags", ProductTag.Type),
}
}
// Hooks of the ProductInfo.
func (ProductInfo) Hooks() []ent.Hook {
return []ent.Hook{
hook.On(NanoIDHook(6), ent.OpCreate),
}
}
// Mixin of the ProductInfo.
func (ProductInfo) Mixin() []ent.Mixin {
return []ent.Mixin{
TimeMixin{},
}
}