-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
84 lines (72 loc) · 2.54 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
// Code generated by ent, DO NOT EDIT.
package user
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/shopspring/decimal"
)
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 = "id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldMoney holds the string denoting the money field in the database.
FieldMoney = "money"
// Table holds the table name of the user in the database.
Table = "users"
)
// Columns holds all SQL columns for user fields.
var Columns = []string{
FieldID,
FieldName,
FieldCreatedAt,
FieldMoney,
}
// 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/entco/integration/gentest/ent/runtime"
var (
Hooks [1]ent.Hook
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultMoney holds the default value on creation for the "money" field.
DefaultMoney func() decimal.Decimal
// MoneyValidator is a validator for the "money" field. It is called by the builders before save.
MoneyValidator func(decimal.Decimal) error
)
// OrderOption defines the ordering options for the User 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()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByMoney orders the results by the money field.
func ByMoney(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMoney, opts...).ToFunc()
}