-
Notifications
You must be signed in to change notification settings - Fork 890
/
user.go
141 lines (128 loc) · 4.61 KB
/
user.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
// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by entc, DO NOT EDIT.
package user
import (
"fmt"
)
const (
// Label holds the string label denoting the user type in the database.
Label = "user"
// FieldID holds the string denoting the id field in the database.
FieldID = "oid"
// FieldAge holds the string denoting the age field in the database.
FieldAge = "age"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldNickname holds the string denoting the nickname field in the database.
FieldNickname = "nickname"
// FieldAddress holds the string denoting the address field in the database.
FieldAddress = "address"
// FieldRenamed holds the string denoting the renamed field in the database.
FieldRenamed = "renamed"
// FieldBlob holds the string denoting the blob field in the database.
FieldBlob = "blob"
// FieldState holds the string denoting the state field in the database.
FieldState = "state"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldWorkplace holds the string denoting the workplace field in the database.
FieldWorkplace = "workplace"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// EdgeSpouse holds the string denoting the spouse edge name in mutations.
EdgeSpouse = "spouse"
// EdgeCar holds the string denoting the car edge name in mutations.
EdgeCar = "car"
// CarFieldID holds the string denoting the ID field of the Car.
CarFieldID = "id"
// Table holds the table name of the user in the database.
Table = "users"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "users"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "user_children"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "users"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "user_children"
// SpouseTable is the table that holds the spouse relation/edge.
SpouseTable = "users"
// SpouseColumn is the table column denoting the spouse relation/edge.
SpouseColumn = "user_spouse"
// CarTable is the table that holds the car relation/edge.
CarTable = "cars"
// CarInverseTable is the table name for the Car entity.
// It exists in this package in order to avoid circular dependency with the "car" package.
CarInverseTable = "cars"
// CarColumn is the table column denoting the car relation/edge.
CarColumn = "user_car"
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldAge,
FieldName,
FieldDescription,
FieldNickname,
FieldAddress,
FieldRenamed,
FieldBlob,
FieldState,
FieldStatus,
FieldWorkplace,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "users"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"user_children",
"user_spouse",
}
// 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
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// BlobValidator is a validator for the "blob" field. It is called by the builders before save.
BlobValidator func([]byte) error
// WorkplaceValidator is a validator for the "workplace" field. It is called by the builders before save.
WorkplaceValidator func(string) error
)
// State defines the type for the "state" enum field.
type State string
// StateLoggedIn is the default value of the State enum.
const DefaultState = StateLoggedIn
// State values.
const (
StateLoggedIn State = "logged_in"
StateLoggedOut State = "logged_out"
)
func (s State) String() string {
return string(s)
}
// StateValidator is a validator for the "state" field enum values. It is called by the builders before save.
func StateValidator(s State) error {
switch s {
case StateLoggedIn, StateLoggedOut:
return nil
default:
return fmt.Errorf("user: invalid enum value for state field: %q", s)
}
}