-
Notifications
You must be signed in to change notification settings - Fork 42
/
perspective.go
45 lines (39 loc) · 1020 Bytes
/
perspective.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
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/seal-io/walrus/pkg/dao/schema/mixin"
"github.com/seal-io/walrus/pkg/dao/types"
)
// Perspective holds the schema definition for cost perspectives.
type Perspective struct {
ent.Schema
}
func (Perspective) Mixin() []ent.Mixin {
return []ent.Mixin{
mixin.Metadata(),
}
}
func (Perspective) Indexes() []ent.Index {
return []ent.Index{
index.Fields("name").
Unique(),
}
}
func (Perspective) Fields() []ent.Field {
return []ent.Field{
field.String("start_time").
Comment("Start time for the perspective.").
NotEmpty(),
field.String("end_time").
Comment("End time for the perspective.").
NotEmpty(),
field.Bool("builtin").
Comment("Is builtin perspective.").
Default(false),
field.JSON("cost_queries", []types.QueryCondition{}).
Comment("Indicated the perspective included cost queries, record the used query condition.").
Default([]types.QueryCondition{}),
}
}