forked from ent/contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.go
98 lines (85 loc) · 3.02 KB
/
category.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
// Code generated by ent, DO NOT EDIT.
package category
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the category type in the database.
Label = "category"
// 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"
// FieldReadonly holds the string denoting the readonly field in the database.
FieldReadonly = "readonly"
// FieldSkipInSpec holds the string denoting the skip_in_spec field in the database.
FieldSkipInSpec = "skip_in_spec"
// EdgePets holds the string denoting the pets edge name in mutations.
EdgePets = "pets"
// Table holds the table name of the category in the database.
Table = "categories"
// PetsTable is the table that holds the pets relation/edge. The primary key declared below.
PetsTable = "category_pets"
// PetsInverseTable is the table name for the Pet entity.
// It exists in this package in order to avoid circular dependency with the "pet" package.
PetsInverseTable = "pets"
)
// Columns holds all SQL columns for category fields.
var Columns = []string{
FieldID,
FieldName,
FieldReadonly,
FieldSkipInSpec,
}
var (
// PetsPrimaryKey and PetsColumn2 are the table columns denoting the
// primary key for the pets relation (M2M).
PetsPrimaryKey = []string{"category_id", "pet_id"}
)
// 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
}
// OrderOption defines the ordering options for the Category 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()
}
// ByReadonly orders the results by the readonly field.
func ByReadonly(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldReadonly, opts...).ToFunc()
}
// BySkipInSpec orders the results by the skip_in_spec field.
func BySkipInSpec(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSkipInSpec, opts...).ToFunc()
}
// ByPetsCount orders the results by pets count.
func ByPetsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newPetsStep(), opts...)
}
}
// ByPets orders the results by pets terms.
func ByPets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPetsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newPetsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(PetsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, PetsTable, PetsPrimaryKey...),
)
}