// Code generated by ent, DO NOT EDIT.

package usermembership

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

const (
	// Label holds the string label denoting the usermembership type in the database.
	Label = "user_membership"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldFirstFailed holds the string denoting the first_failed field in the database.
	FieldFirstFailed = "first_failed"
	// FieldLastVerified holds the string denoting the last_verified field in the database.
	FieldLastVerified = "last_verified"
	// FieldFailCount holds the string denoting the fail_count field in the database.
	FieldFailCount = "fail_count"
	// EdgeUser holds the string denoting the user edge name in mutations.
	EdgeUser = "user"
	// EdgeYoutubeTalent holds the string denoting the youtube_talent edge name in mutations.
	EdgeYoutubeTalent = "youtube_talent"
	// EdgeRoles holds the string denoting the roles edge name in mutations.
	EdgeRoles = "roles"
	// Table holds the table name of the usermembership in the database.
	Table = "user_memberships"
	// UserTable is the table that holds the user relation/edge.
	UserTable = "user_memberships"
	// UserInverseTable is the table name for the User entity.
	// It exists in this package in order to avoid circular dependency with the "user" package.
	UserInverseTable = "users"
	// UserColumn is the table column denoting the user relation/edge.
	UserColumn = "user_memberships"
	// YoutubeTalentTable is the table that holds the youtube_talent relation/edge.
	YoutubeTalentTable = "user_memberships"
	// YoutubeTalentInverseTable is the table name for the YouTubeTalent entity.
	// It exists in this package in order to avoid circular dependency with the "youtubetalent" package.
	YoutubeTalentInverseTable = "you_tube_talents"
	// YoutubeTalentColumn is the table column denoting the youtube_talent relation/edge.
	YoutubeTalentColumn = "user_membership_youtube_talent"
	// RolesTable is the table that holds the roles relation/edge. The primary key declared below.
	RolesTable = "user_membership_roles"
	// RolesInverseTable is the table name for the GuildRole entity.
	// It exists in this package in order to avoid circular dependency with the "guildrole" package.
	RolesInverseTable = "guild_roles"
)

// Columns holds all SQL columns for usermembership fields.
var Columns = []string{
	FieldID,
	FieldFirstFailed,
	FieldLastVerified,
	FieldFailCount,
}

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

var (
	// RolesPrimaryKey and RolesColumn2 are the table columns denoting the
	// primary key for the roles relation (M2M).
	RolesPrimaryKey = []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 (
	// DefaultFailCount holds the default value on creation for the "fail_count" field.
	DefaultFailCount int
)

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

// ByFirstFailed orders the results by the first_failed field.
func ByFirstFailed(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFirstFailed, opts...).ToFunc()
}

// ByLastVerified orders the results by the last_verified field.
func ByLastVerified(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastVerified, opts...).ToFunc()
}

// ByFailCount orders the results by the fail_count field.
func ByFailCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFailCount, opts...).ToFunc()
}

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

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

// 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 newUserStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UserInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
	)
}
func newYoutubeTalentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(YoutubeTalentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, false, YoutubeTalentTable, YoutubeTalentColumn),
	)
}
func newRolesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RolesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...),
	)
}
