portfolio/ent/user/user.go
darius 08fc61d643 User model update
Docker orm update
2024-02-14 12:39:10 +01:00

87 lines
2.0 KiB
Go

// Code generated by ent, DO NOT EDIT.
package user
import (
"fmt"
"entgo.io/ent/dialect/sql"
)
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"
// FieldRole holds the string denoting the role field in the database.
FieldRole = "role"
// 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,
FieldRole,
}
// 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 (
// DefaultName holds the default value on creation for the "name" field.
DefaultName string
)
// Role defines the type for the "role" enum field.
type Role string
// Role values.
const (
RoleAdmin Role = "admin"
RoleUser Role = "user"
RoleVisitor Role = "visitor"
)
func (r Role) String() string {
return string(r)
}
// RoleValidator is a validator for the "role" field enum values. It is called by the builders before save.
func RoleValidator(r Role) error {
switch r {
case RoleAdmin, RoleUser, RoleVisitor:
return nil
default:
return fmt.Errorf("user: invalid enum value for role field: %q", r)
}
}
// 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()
}
// ByRole orders the results by the role field.
func ByRole(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRole, opts...).ToFunc()
}