| 1 |
// Code generated by ent, DO NOT EDIT. |
| 2 |
|
| 3 |
package subject |
| 4 |
|
| 5 |
import ( |
| 6 |
"time" |
| 7 |
|
| 8 |
"entgo.io/ent/dialect/sql" |
| 9 |
"entgo.io/ent/dialect/sql/sqlgraph" |
| 10 |
"github.com/google/uuid" |
| 11 |
) |
| 12 |
|
| 13 |
const ( |
| 14 |
// Label holds the string label denoting the subject type in the database. |
| 15 |
Label = "subject" |
| 16 |
// FieldID holds the string denoting the id field in the database. |
| 17 |
FieldID = "id" |
| 18 |
// FieldCreatedAt holds the string denoting the created_at field in the database. |
| 19 |
FieldCreatedAt = "created_at" |
| 20 |
// FieldName holds the string denoting the name field in the database. |
| 21 |
FieldName = "name" |
| 22 |
// EdgeSubjectDigests holds the string denoting the subject_digests edge name in mutations. |
| 23 |
EdgeSubjectDigests = "subject_digests" |
| 24 |
// EdgeStatement holds the string denoting the statement edge name in mutations. |
| 25 |
EdgeStatement = "statement" |
| 26 |
// Table holds the table name of the subject in the database. |
| 27 |
Table = "subjects" |
| 28 |
// SubjectDigestsTable is the table that holds the subject_digests relation/edge. |
| 29 |
SubjectDigestsTable = "subject_digests" |
| 30 |
// SubjectDigestsInverseTable is the table name for the SubjectDigest entity. |
| 31 |
// It exists in this package in order to avoid circular dependency with the "subjectdigest" package. |
| 32 |
SubjectDigestsInverseTable = "subject_digests" |
| 33 |
// SubjectDigestsColumn is the table column denoting the subject_digests relation/edge. |
| 34 |
SubjectDigestsColumn = "subject_subject_digests" |
| 35 |
// StatementTable is the table that holds the statement relation/edge. |
| 36 |
StatementTable = "subjects" |
| 37 |
// StatementInverseTable is the table name for the Statement entity. |
| 38 |
// It exists in this package in order to avoid circular dependency with the "statement" package. |
| 39 |
StatementInverseTable = "statements" |
| 40 |
// StatementColumn is the table column denoting the statement relation/edge. |
| 41 |
StatementColumn = "statement_subjects" |
| 42 |
) |
| 43 |
|
| 44 |
// Columns holds all SQL columns for subject fields. |
| 45 |
var Columns = []string{ |
| 46 |
FieldID, |
| 47 |
FieldCreatedAt, |
| 48 |
FieldName, |
| 49 |
} |
| 50 |
|
| 51 |
// ForeignKeys holds the SQL foreign-keys that are owned by the "subjects" |
| 52 |
// table and are not defined as standalone fields in the schema. |
| 53 |
var ForeignKeys = []string{ |
| 54 |
"statement_subjects", |
| 55 |
} |
| 56 |
|
| 57 |
// ValidColumn reports if the column name is valid (part of the table columns). |
| 58 |
func ValidColumn(column string) bool { |
| 59 |
for i := range Columns { |
| 60 |
if column == Columns[i] { |
| 61 |
return true |
| 62 |
} |
| 63 |
} |
| 64 |
for i := range ForeignKeys { |
| 65 |
if column == ForeignKeys[i] { |
| 66 |
return true |
| 67 |
} |
| 68 |
} |
| 69 |
return false |
| 70 |
} |
| 71 |
|
| 72 |
var ( |
| 73 |
// DefaultCreatedAt holds the default value on creation for the "created_at" field. |
| 74 |
DefaultCreatedAt func() time.Time |
| 75 |
// NameValidator is a validator for the "name" field. It is called by the builders before save. |
| 76 |
NameValidator func(string) error |
| 77 |
// DefaultID holds the default value on creation for the "id" field. |
| 78 |
DefaultID func() uuid.UUID |
| 79 |
) |
| 80 |
|
| 81 |
// OrderOption defines the ordering options for the Subject queries. |
| 82 |
type OrderOption func(*sql.Selector) |
| 83 |
|
| 84 |
// ByID orders the results by the id field. |
| 85 |
func ByID(opts ...sql.OrderTermOption) OrderOption { |
| 86 |
return sql.OrderByField(FieldID, opts...).ToFunc() |
| 87 |
} |
| 88 |
|
| 89 |
// ByCreatedAt orders the results by the created_at field. |
| 90 |
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { |
| 91 |
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() |
| 92 |
} |
| 93 |
|
| 94 |
// ByName orders the results by the name field. |
| 95 |
func ByName(opts ...sql.OrderTermOption) OrderOption { |
| 96 |
return sql.OrderByField(FieldName, opts...).ToFunc() |
| 97 |
} |
| 98 |
|
| 99 |
// BySubjectDigestsCount orders the results by subject_digests count. |
| 100 |
func BySubjectDigestsCount(opts ...sql.OrderTermOption) OrderOption { |
| 101 |
return func(s *sql.Selector) { |
| 102 |
sqlgraph.OrderByNeighborsCount(s, newSubjectDigestsStep(), opts...) |
| 103 |
} |
| 104 |
} |
| 105 |
|
| 106 |
// BySubjectDigests orders the results by subject_digests terms. |
| 107 |
func BySubjectDigests(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { |
| 108 |
return func(s *sql.Selector) { |
| 109 |
sqlgraph.OrderByNeighborTerms(s, newSubjectDigestsStep(), append([]sql.OrderTerm{term}, terms...)...) |
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
// ByStatementField orders the results by statement field. |
| 114 |
func ByStatementField(field string, opts ...sql.OrderTermOption) OrderOption { |
| 115 |
return func(s *sql.Selector) { |
| 116 |
sqlgraph.OrderByNeighborTerms(s, newStatementStep(), sql.OrderByField(field, opts...)) |
| 117 |
} |
| 118 |
} |
| 119 |
func newSubjectDigestsStep() *sqlgraph.Step { |
| 120 |
return sqlgraph.NewStep( |
| 121 |
sqlgraph.From(Table, FieldID), |
| 122 |
sqlgraph.To(SubjectDigestsInverseTable, FieldID), |
| 123 |
sqlgraph.Edge(sqlgraph.O2M, false, SubjectDigestsTable, SubjectDigestsColumn), |
| 124 |
) |
| 125 |
} |
| 126 |
func newStatementStep() *sqlgraph.Step { |
| 127 |
return sqlgraph.NewStep( |
| 128 |
sqlgraph.From(Table, FieldID), |
| 129 |
sqlgraph.To(StatementInverseTable, FieldID), |
| 130 |
sqlgraph.Edge(sqlgraph.M2O, true, StatementTable, StatementColumn), |
| 131 |
) |
| 132 |
} |