160 lines
5.4 KiB
Go
160 lines
5.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package user
|
|
|
|
import (
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
)
|
|
|
|
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"
|
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
|
FieldCreatedAt = "created_at"
|
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
|
FieldUpdatedAt = "updated_at"
|
|
// FieldUsername holds the string denoting the username field in the database.
|
|
FieldUsername = "username"
|
|
// FieldPassword holds the string denoting the password field in the database.
|
|
FieldPassword = "password"
|
|
// FieldNickname holds the string denoting the nickname field in the database.
|
|
FieldNickname = "nickname"
|
|
// FieldEmail holds the string denoting the email field in the database.
|
|
FieldEmail = "email"
|
|
// FieldIP holds the string denoting the ip field in the database.
|
|
FieldIP = "ip"
|
|
// FieldAddr holds the string denoting the addr field in the database.
|
|
FieldAddr = "addr"
|
|
// EdgeRoles holds the string denoting the roles edge name in mutations.
|
|
EdgeRoles = "roles"
|
|
// Table holds the table name of the user in the database.
|
|
Table = "users"
|
|
// RolesTable is the table that holds the roles relation/edge. The primary key declared below.
|
|
RolesTable = "user_roles"
|
|
// RolesInverseTable is the table name for the Role entity.
|
|
// It exists in this package in order to avoid circular dependency with the "role" package.
|
|
RolesInverseTable = "roles"
|
|
)
|
|
|
|
// Columns holds all SQL columns for user fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldCreatedAt,
|
|
FieldUpdatedAt,
|
|
FieldUsername,
|
|
FieldPassword,
|
|
FieldNickname,
|
|
FieldEmail,
|
|
FieldIP,
|
|
FieldAddr,
|
|
}
|
|
|
|
var (
|
|
// RolesPrimaryKey and RolesColumn2 are the table columns denoting the
|
|
// primary key for the roles relation (M2M).
|
|
RolesPrimaryKey = []string{"user_id", "role_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
|
|
}
|
|
|
|
var (
|
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
|
DefaultCreatedAt func() time.Time
|
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
|
DefaultUpdatedAt func() time.Time
|
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
|
UpdateDefaultUpdatedAt func() time.Time
|
|
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
|
UsernameValidator func(string) error
|
|
// NicknameValidator is a validator for the "nickname" field. It is called by the builders before save.
|
|
NicknameValidator func(string) error
|
|
// EmailValidator is a validator for the "email" field. It is called by the builders before save.
|
|
EmailValidator func(string) error
|
|
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
|
|
IPValidator func(string) error
|
|
// AddrValidator is a validator for the "addr" field. It is called by the builders before save.
|
|
AddrValidator func(string) 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()
|
|
}
|
|
|
|
// ByCreatedAt orders the results by the created_at field.
|
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUpdatedAt orders the results by the updated_at field.
|
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
|
}
|
|
|
|
// ByUsername orders the results by the username field.
|
|
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldUsername, opts...).ToFunc()
|
|
}
|
|
|
|
// ByPassword orders the results by the password field.
|
|
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldPassword, opts...).ToFunc()
|
|
}
|
|
|
|
// ByNickname orders the results by the nickname field.
|
|
func ByNickname(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldNickname, opts...).ToFunc()
|
|
}
|
|
|
|
// ByEmail orders the results by the email field.
|
|
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldEmail, opts...).ToFunc()
|
|
}
|
|
|
|
// ByIP orders the results by the ip field.
|
|
func ByIP(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldIP, opts...).ToFunc()
|
|
}
|
|
|
|
// ByAddr orders the results by the addr field.
|
|
func ByAddr(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldAddr, opts...).ToFunc()
|
|
}
|
|
|
|
// ByRolesCount orders the results by roles count.
|
|
func ByRolesCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...)
|
|
}
|
|
}
|
|
|
|
// ByRoles orders the results by roles terms.
|
|
func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...)
|
|
}
|
|
}
|
|
func newRolesStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(RolesInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...),
|
|
)
|
|
}
|