// Code generated by ent, DO NOT EDIT.

package user

import (
	"time"

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

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"
	// FieldFullName holds the string denoting the full_name field in the database.
	FieldFullName = "full_name"
	// FieldAvatarHash holds the string denoting the avatar_hash field in the database.
	FieldAvatarHash = "avatar_hash"
	// FieldLastCheck holds the string denoting the last_check field in the database.
	FieldLastCheck = "last_check"
	// FieldYoutubeID holds the string denoting the youtube_id field in the database.
	FieldYoutubeID = "youtube_id"
	// FieldYoutubeToken holds the string denoting the youtube_token field in the database.
	FieldYoutubeToken = "youtube_token"
	// FieldDiscordToken holds the string denoting the discord_token field in the database.
	FieldDiscordToken = "discord_token"
	// EdgeGuilds holds the string denoting the guilds edge name in mutations.
	EdgeGuilds = "guilds"
	// EdgeGuildsAdmin holds the string denoting the guilds_admin edge name in mutations.
	EdgeGuildsAdmin = "guilds_admin"
	// EdgeMemberships holds the string denoting the memberships edge name in mutations.
	EdgeMemberships = "memberships"
	// Table holds the table name of the user in the database.
	Table = "users"
	// GuildsTable is the table that holds the guilds relation/edge. The primary key declared below.
	GuildsTable = "guild_members"
	// GuildsInverseTable is the table name for the Guild entity.
	// It exists in this package in order to avoid circular dependency with the "guild" package.
	GuildsInverseTable = "guilds"
	// GuildsAdminTable is the table that holds the guilds_admin relation/edge. The primary key declared below.
	GuildsAdminTable = "guild_admins"
	// GuildsAdminInverseTable is the table name for the Guild entity.
	// It exists in this package in order to avoid circular dependency with the "guild" package.
	GuildsAdminInverseTable = "guilds"
	// MembershipsTable is the table that holds the memberships relation/edge.
	MembershipsTable = "user_memberships"
	// MembershipsInverseTable is the table name for the UserMembership entity.
	// It exists in this package in order to avoid circular dependency with the "usermembership" package.
	MembershipsInverseTable = "user_memberships"
	// MembershipsColumn is the table column denoting the memberships relation/edge.
	MembershipsColumn = "user_memberships"
)

// Columns holds all SQL columns for user fields.
var Columns = []string{
	FieldID,
	FieldFullName,
	FieldAvatarHash,
	FieldLastCheck,
	FieldYoutubeID,
	FieldYoutubeToken,
	FieldDiscordToken,
}

var (
	// GuildsPrimaryKey and GuildsColumn2 are the table columns denoting the
	// primary key for the guilds relation (M2M).
	GuildsPrimaryKey = []string{"guild_id", "user_id"}
	// GuildsAdminPrimaryKey and GuildsAdminColumn2 are the table columns denoting the
	// primary key for the guilds_admin relation (M2M).
	GuildsAdminPrimaryKey = []string{"guild_id", "user_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 (
	// DefaultLastCheck holds the default value on creation for the "last_check" field.
	DefaultLastCheck func() time.Time
)

// 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()
}

// ByFullName orders the results by the full_name field.
func ByFullName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFullName, opts...).ToFunc()
}

// ByAvatarHash orders the results by the avatar_hash field.
func ByAvatarHash(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAvatarHash, opts...).ToFunc()
}

// ByLastCheck orders the results by the last_check field.
func ByLastCheck(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastCheck, opts...).ToFunc()
}

// ByYoutubeID orders the results by the youtube_id field.
func ByYoutubeID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldYoutubeID, opts...).ToFunc()
}

// ByGuildsCount orders the results by guilds count.
func ByGuildsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newGuildsStep(), opts...)
	}
}

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

// ByGuildsAdminCount orders the results by guilds_admin count.
func ByGuildsAdminCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newGuildsAdminStep(), opts...)
	}
}

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

// ByMembershipsCount orders the results by memberships count.
func ByMembershipsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newMembershipsStep(), opts...)
	}
}

// ByMemberships orders the results by memberships terms.
func ByMemberships(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newMembershipsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newGuildsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(GuildsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, true, GuildsTable, GuildsPrimaryKey...),
	)
}
func newGuildsAdminStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(GuildsAdminInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, true, GuildsAdminTable, GuildsAdminPrimaryKey...),
	)
}
func newMembershipsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(MembershipsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, MembershipsTable, MembershipsColumn),
	)
}
