invitation.go•5.39 kB
// Code generated by ent, DO NOT EDIT.
package invitation
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 invitation type in the database.
Label = "invitation"
// 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"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldMessage holds the string denoting the message field in the database.
FieldMessage = "message"
// FieldCreatorAccountID holds the string denoting the creator_account_id field in the database.
FieldCreatorAccountID = "creator_account_id"
// EdgeCreator holds the string denoting the creator edge name in mutations.
EdgeCreator = "creator"
// EdgeInvited holds the string denoting the invited edge name in mutations.
EdgeInvited = "invited"
// Table holds the table name of the invitation in the database.
Table = "invitations"
// CreatorTable is the table that holds the creator relation/edge.
CreatorTable = "invitations"
// CreatorInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
CreatorInverseTable = "accounts"
// CreatorColumn is the table column denoting the creator relation/edge.
CreatorColumn = "creator_account_id"
// InvitedTable is the table that holds the invited relation/edge.
InvitedTable = "accounts"
// InvitedInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
InvitedInverseTable = "accounts"
// InvitedColumn is the table column denoting the invited relation/edge.
InvitedColumn = "invited_by_id"
)
// Columns holds all SQL columns for invitation fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldMessage,
FieldCreatorAccountID,
}
// 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
// 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 Invitation 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()
}
// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByMessage orders the results by the message field.
func ByMessage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMessage, opts...).ToFunc()
}
// ByCreatorAccountID orders the results by the creator_account_id field.
func ByCreatorAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatorAccountID, opts...).ToFunc()
}
// ByCreatorField orders the results by creator field.
func ByCreatorField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCreatorStep(), sql.OrderByField(field, opts...))
}
}
// ByInvitedCount orders the results by invited count.
func ByInvitedCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newInvitedStep(), opts...)
}
}
// ByInvited orders the results by invited terms.
func ByInvited(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newInvitedStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newCreatorStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(CreatorInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, CreatorTable, CreatorColumn),
)
}
func newInvitedStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(InvitedInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, InvitedTable, InvitedColumn),
)
}