/
runtime.go
59 lines (55 loc) · 2.36 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
// Code generated by entc, DO NOT EDIT.
package ent
import (
"time"
"github.com/long2ice/longurl/ent/schema"
"github.com/long2ice/longurl/ent/url"
"github.com/long2ice/longurl/ent/visitlog"
)
// 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() {
urlFields := schema.Url{}.Fields()
_ = urlFields
// urlDescURL is the schema descriptor for url field.
urlDescURL := urlFields[0].Descriptor()
// url.URLValidator is a validator for the "url" field. It is called by the builders before save.
url.URLValidator = urlDescURL.Validators[0].(func(string) error)
// urlDescPath is the schema descriptor for path field.
urlDescPath := urlFields[1].Descriptor()
// url.PathValidator is a validator for the "path" field. It is called by the builders before save.
url.PathValidator = func() func(string) error {
validators := urlDescPath.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(_path string) error {
for _, fn := range fns {
if err := fn(_path); err != nil {
return err
}
}
return nil
}
}()
// urlDescCurrentTimes is the schema descriptor for current_times field.
urlDescCurrentTimes := urlFields[2].Descriptor()
// url.DefaultCurrentTimes holds the default value on creation for the current_times field.
url.DefaultCurrentTimes = urlDescCurrentTimes.Default.(int)
// urlDescMaxTimes is the schema descriptor for max_times field.
urlDescMaxTimes := urlFields[3].Descriptor()
// url.DefaultMaxTimes holds the default value on creation for the max_times field.
url.DefaultMaxTimes = urlDescMaxTimes.Default.(int)
// urlDescCreatedAt is the schema descriptor for created_at field.
urlDescCreatedAt := urlFields[5].Descriptor()
// url.DefaultCreatedAt holds the default value on creation for the created_at field.
url.DefaultCreatedAt = urlDescCreatedAt.Default.(func() time.Time)
visitlogFields := schema.VisitLog{}.Fields()
_ = visitlogFields
// visitlogDescCreatedAt is the schema descriptor for created_at field.
visitlogDescCreatedAt := visitlogFields[11].Descriptor()
// visitlog.DefaultCreatedAt holds the default value on creation for the created_at field.
visitlog.DefaultCreatedAt = visitlogDescCreatedAt.Default.(func() time.Time)
}