-
Notifications
You must be signed in to change notification settings - Fork 1
/
filesource.go
204 lines (178 loc) · 6.31 KB
/
filesource.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// Code generated by ent, DO NOT EDIT.
package filesource
import (
"fmt"
"io"
"strconv"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the filesource type in the database.
Label = "file_source"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedBy holds the string denoting the created_by field in the database.
FieldCreatedBy = "created_by"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedBy holds the string denoting the updated_by field in the database.
FieldUpdatedBy = "updated_by"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldKind holds the string denoting the kind field in the database.
FieldKind = "kind"
// FieldComments holds the string denoting the comments field in the database.
FieldComments = "comments"
// FieldEndpoint holds the string denoting the endpoint field in the database.
FieldEndpoint = "endpoint"
// FieldRegion holds the string denoting the region field in the database.
FieldRegion = "region"
// FieldBucket holds the string denoting the bucket field in the database.
FieldBucket = "bucket"
// EdgeFiles holds the string denoting the files edge name in mutations.
EdgeFiles = "files"
// Table holds the table name of the filesource in the database.
Table = "file_source"
// FilesTable is the table that holds the files relation/edge.
FilesTable = "file"
// FilesInverseTable is the table name for the File entity.
// It exists in this package in order to avoid circular dependency with the "file" package.
FilesInverseTable = "file"
// FilesColumn is the table column denoting the files relation/edge.
FilesColumn = "source_id"
)
// Columns holds all SQL columns for filesource fields.
var Columns = []string{
FieldID,
FieldCreatedBy,
FieldCreatedAt,
FieldUpdatedBy,
FieldUpdatedAt,
FieldKind,
FieldComments,
FieldEndpoint,
FieldRegion,
FieldBucket,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "github.com/woocoos/knockout/ent/runtime"
var (
Hooks [2]ent.Hook
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// RegionValidator is a validator for the "region" field. It is called by the builders before save.
RegionValidator func(string) error
// BucketValidator is a validator for the "bucket" field. It is called by the builders before save.
BucketValidator func(string) error
)
// Kind defines the type for the "kind" enum field.
type Kind string
// Kind values.
const (
KindLocal Kind = "local"
KindAlioss Kind = "alioss"
)
func (k Kind) String() string {
return string(k)
}
// KindValidator is a validator for the "kind" field enum values. It is called by the builders before save.
func KindValidator(k Kind) error {
switch k {
case KindLocal, KindAlioss:
return nil
default:
return fmt.Errorf("filesource: invalid enum value for kind field: %q", k)
}
}
// OrderOption defines the ordering options for the FileSource queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedBy orders the results by the created_by field.
func ByCreatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedBy, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedBy orders the results by the updated_by field.
func ByUpdatedBy(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedBy, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByKind orders the results by the kind field.
func ByKind(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldKind, opts...).ToFunc()
}
// ByComments orders the results by the comments field.
func ByComments(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldComments, opts...).ToFunc()
}
// ByEndpoint orders the results by the endpoint field.
func ByEndpoint(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEndpoint, opts...).ToFunc()
}
// ByRegion orders the results by the region field.
func ByRegion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRegion, opts...).ToFunc()
}
// ByBucket orders the results by the bucket field.
func ByBucket(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBucket, opts...).ToFunc()
}
// ByFilesCount orders the results by files count.
func ByFilesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newFilesStep(), opts...)
}
}
// ByFiles orders the results by files terms.
func ByFiles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newFilesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newFilesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(FilesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, FilesTable, FilesColumn),
)
}
// MarshalGQL implements graphql.Marshaler interface.
func (e Kind) MarshalGQL(w io.Writer) {
io.WriteString(w, strconv.Quote(e.String()))
}
// UnmarshalGQL implements graphql.Unmarshaler interface.
func (e *Kind) UnmarshalGQL(val interface{}) error {
str, ok := val.(string)
if !ok {
return fmt.Errorf("enum %T must be a string", val)
}
*e = Kind(str)
if err := KindValidator(*e); err != nil {
return fmt.Errorf("%s is not a valid Kind", str)
}
return nil
}