// Code generated by ent, DO NOT EDIT.

package guildrole

import (
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the guildrole type in the database.
	Label = "guild_role"
	// 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"
	// FieldLastUpdated holds the string denoting the last_updated field in the database.
	FieldLastUpdated = "last_updated"
	// EdgeGuild holds the string denoting the guild edge name in mutations.
	EdgeGuild = "guild"
	// EdgeUserMemberships holds the string denoting the user_memberships edge name in mutations.
	EdgeUserMemberships = "user_memberships"
	// EdgeTalent holds the string denoting the talent edge name in mutations.
	EdgeTalent = "talent"
	// Table holds the table name of the guildrole in the database.
	Table = "guild_roles"
	// GuildTable is the table that holds the guild relation/edge.
	GuildTable = "guild_roles"
	// GuildInverseTable is the table name for the Guild entity.
	// It exists in this package in order to avoid circular dependency with the "guild" package.
	GuildInverseTable = "guilds"
	// GuildColumn is the table column denoting the guild relation/edge.
	GuildColumn = "guild_roles"
	// UserMembershipsTable is the table that holds the user_memberships relation/edge. The primary key declared below.
	UserMembershipsTable = "user_membership_roles"
	// UserMembershipsInverseTable is the table name for the UserMembership entity.
	// It exists in this package in order to avoid circular dependency with the "usermembership" package.
	UserMembershipsInverseTable = "user_memberships"
	// TalentTable is the table that holds the talent relation/edge.
	TalentTable = "guild_roles"
	// TalentInverseTable is the table name for the YouTubeTalent entity.
	// It exists in this package in order to avoid circular dependency with the "youtubetalent" package.
	TalentInverseTable = "you_tube_talents"
	// TalentColumn is the table column denoting the talent relation/edge.
	TalentColumn = "you_tube_talent_roles"
)

// Columns holds all SQL columns for guildrole fields.
var Columns = []string{
	FieldID,
	FieldName,
	FieldLastUpdated,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "guild_roles"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"guild_roles",
	"you_tube_talent_roles",
}

var (
	// UserMembershipsPrimaryKey and UserMembershipsColumn2 are the table columns denoting the
	// primary key for the user_memberships relation (M2M).
	UserMembershipsPrimaryKey = []string{"user_membership_id", "guild_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
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

var (
	// DefaultLastUpdated holds the default value on creation for the "last_updated" field.
	DefaultLastUpdated func() time.Time
)

// OrderOption defines the ordering options for the GuildRole 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()
}

// ByLastUpdated orders the results by the last_updated field.
func ByLastUpdated(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastUpdated, opts...).ToFunc()
}

// ByGuildField orders the results by guild field.
func ByGuildField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newGuildStep(), sql.OrderByField(field, opts...))
	}
}

// ByUserMembershipsCount orders the results by user_memberships count.
func ByUserMembershipsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newUserMembershipsStep(), opts...)
	}
}

// ByUserMemberships orders the results by user_memberships terms.
func ByUserMemberships(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newUserMembershipsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByTalentField orders the results by talent field.
func ByTalentField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTalentStep(), sql.OrderByField(field, opts...))
	}
}
func newGuildStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(GuildInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, GuildTable, GuildColumn),
	)
}
func newUserMembershipsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UserMembershipsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, true, UserMembershipsTable, UserMembershipsPrimaryKey...),
	)
}
func newTalentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TalentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, TalentTable, TalentColumn),
	)
}
