role.go•5.95 kB
// Code generated by ent, DO NOT EDIT.
package role
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/rs/xid"
)
const (
// Label holds the string label denoting the role type in the database.
Label = "role"
// 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"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldColour holds the string denoting the colour field in the database.
FieldColour = "colour"
// FieldPermissions holds the string denoting the permissions field in the database.
FieldPermissions = "permissions"
// FieldSortKey holds the string denoting the sort_key field in the database.
FieldSortKey = "sort_key"
// EdgeAccounts holds the string denoting the accounts edge name in mutations.
EdgeAccounts = "accounts"
// EdgeAccountRoles holds the string denoting the account_roles edge name in mutations.
EdgeAccountRoles = "account_roles"
// Table holds the table name of the role in the database.
Table = "roles"
// AccountsTable is the table that holds the accounts relation/edge. The primary key declared below.
AccountsTable = "account_roles"
// AccountsInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
AccountsInverseTable = "accounts"
// AccountRolesTable is the table that holds the account_roles relation/edge.
AccountRolesTable = "account_roles"
// AccountRolesInverseTable is the table name for the AccountRoles entity.
// It exists in this package in order to avoid circular dependency with the "accountroles" package.
AccountRolesInverseTable = "account_roles"
// AccountRolesColumn is the table column denoting the account_roles relation/edge.
AccountRolesColumn = "role_id"
)
// Columns holds all SQL columns for role fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldName,
FieldColour,
FieldPermissions,
FieldSortKey,
}
var (
// AccountsPrimaryKey and AccountsColumn2 are the table columns denoting the
// primary key for the accounts relation (M2M).
AccountsPrimaryKey = []string{"role_id", "account_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
// DefaultColour holds the default value on creation for the "colour" field.
DefaultColour string
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() xid.ID
// IDValidator is a validator for the "id" field. It is called by the builders before save.
IDValidator func(string) error
)
// OrderOption defines the ordering options for the Role 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()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByColour orders the results by the colour field.
func ByColour(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldColour, opts...).ToFunc()
}
// BySortKey orders the results by the sort_key field.
func BySortKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSortKey, opts...).ToFunc()
}
// ByAccountsCount orders the results by accounts count.
func ByAccountsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAccountsStep(), opts...)
}
}
// ByAccounts orders the results by accounts terms.
func ByAccounts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAccountsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByAccountRolesCount orders the results by account_roles count.
func ByAccountRolesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAccountRolesStep(), opts...)
}
}
// ByAccountRoles orders the results by account_roles terms.
func ByAccountRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAccountRolesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newAccountsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AccountsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, AccountsTable, AccountsPrimaryKey...),
)
}
func newAccountRolesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AccountRolesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, AccountRolesTable, AccountRolesColumn),
)
}