-
Notifications
You must be signed in to change notification settings - Fork 0
/
product_color.go
54 lines (47 loc) · 1.03 KB
/
product_color.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
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"github.com/thaiha1607/foursquare_server/ent/hook"
)
// ProductColor holds the schema definition for the ProductColor entity.
type ProductColor struct {
ent.Schema
}
// Annotations of the ProductColor.
func (ProductColor) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "product_color"},
}
}
// Fields of the ProductColor.
func (ProductColor) Fields() []ent.Field {
return []ent.Field{
field.String("id").
NotEmpty().
Unique().
MinLen(4),
field.String("name").
NotEmpty(),
field.String("color_code").
NotEmpty(),
}
}
// Edges of the ProductColor.
func (ProductColor) Edges() []ent.Edge {
return nil
}
// Hooks of the ProductColor.
func (ProductColor) Hooks() []ent.Hook {
return []ent.Hook{
hook.On(NanoIDHook(4), ent.OpCreate),
}
}
// Mixin of the ProductColor.
func (ProductColor) Mixin() []ent.Mixin {
return []ent.Mixin{
TimeMixin{},
}
}