generated from ent/bug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.go
75 lines (69 loc) · 2.89 KB
/
runtime.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
69
70
71
72
73
74
75
// Code generated by ent, DO NOT EDIT.
package runtime
import (
"context"
"time"
"github.com/lrstanley/ent-bug-edge-schema/internal/database/ent/like"
"github.com/lrstanley/ent-bug-edge-schema/internal/database/ent/tweet"
"github.com/lrstanley/ent-bug-edge-schema/internal/database/ent/user"
"github.com/lrstanley/ent-bug-edge-schema/internal/database/schema"
"entgo.io/ent"
"entgo.io/ent/privacy"
)
// The init function reads all schema descriptors with runtime code
// (default values, validators, hooks and policies) and stitches it
// to their package variables.
func init() {
likeMixin := schema.Like{}.Mixin()
like.Policy = privacy.NewPolicies(schema.Like{})
like.Hooks[0] = func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if err := like.Policy.EvalMutation(ctx, m); err != nil {
return nil, err
}
return next.Mutate(ctx, m)
})
}
likeMixinFields0 := likeMixin[0].Fields()
_ = likeMixinFields0
likeMixinFields1 := likeMixin[1].Fields()
_ = likeMixinFields1
likeFields := schema.Like{}.Fields()
_ = likeFields
// likeDescCreateTime is the schema descriptor for create_time field.
likeDescCreateTime := likeMixinFields0[0].Descriptor()
// like.DefaultCreateTime holds the default value on creation for the create_time field.
like.DefaultCreateTime = likeDescCreateTime.Default.(func() time.Time)
// likeDescUpdateTime is the schema descriptor for update_time field.
likeDescUpdateTime := likeMixinFields1[0].Descriptor()
// like.DefaultUpdateTime holds the default value on creation for the update_time field.
like.DefaultUpdateTime = likeDescUpdateTime.Default.(func() time.Time)
// like.UpdateDefaultUpdateTime holds the default value on update for the update_time field.
like.UpdateDefaultUpdateTime = likeDescUpdateTime.UpdateDefault.(func() time.Time)
// likeDescLikedAt is the schema descriptor for liked_at field.
likeDescLikedAt := likeFields[0].Descriptor()
// like.DefaultLikedAt holds the default value on creation for the liked_at field.
like.DefaultLikedAt = likeDescLikedAt.Default.(func() time.Time)
tweet.Policy = privacy.NewPolicies(schema.Tweet{})
tweet.Hooks[0] = func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if err := tweet.Policy.EvalMutation(ctx, m); err != nil {
return nil, err
}
return next.Mutate(ctx, m)
})
}
user.Policy = privacy.NewPolicies(schema.User{})
user.Hooks[0] = func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if err := user.Policy.EvalMutation(ctx, m); err != nil {
return nil, err
}
return next.Mutate(ctx, m)
})
}
}
const (
Version = "v0.12.5" // Version of ent codegen.
Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen.
)