// Code generated by ent, DO NOT EDIT.

package account

import (
	"fmt"
	"time"

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

const (
	// Label holds the string label denoting the account type in the database.
	Label = "account"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldKind holds the string denoting the kind field in the database.
	FieldKind = "kind"
	// FieldDisplayName holds the string denoting the display_name field in the database.
	FieldDisplayName = "display_name"
	// FieldSettings holds the string denoting the settings field in the database.
	FieldSettings = "settings"
	// FieldNeedsReauth holds the string denoting the needs_reauth field in the database.
	FieldNeedsReauth = "needs_reauth"
	// FieldAuthError holds the string denoting the auth_error field in the database.
	FieldAuthError = "auth_error"
	// FieldSyncNotice holds the string denoting the sync_notice field in the database.
	FieldSyncNotice = "sync_notice"
	// 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"
	// EdgeCalendars holds the string denoting the calendars edge name in mutations.
	EdgeCalendars = "calendars"
	// EdgeSecrets holds the string denoting the secrets edge name in mutations.
	EdgeSecrets = "secrets"
	// Table holds the table name of the account in the database.
	Table = "accounts"
	// CalendarsTable is the table that holds the calendars relation/edge.
	CalendarsTable = "calendars"
	// CalendarsInverseTable is the table name for the Calendar entity.
	// It exists in this package in order to avoid circular dependency with the "calendar" package.
	CalendarsInverseTable = "calendars"
	// CalendarsColumn is the table column denoting the calendars relation/edge.
	CalendarsColumn = "account_calendars"
	// SecretsTable is the table that holds the secrets relation/edge.
	SecretsTable = "secrets"
	// SecretsInverseTable is the table name for the Secret entity.
	// It exists in this package in order to avoid circular dependency with the "secret" package.
	SecretsInverseTable = "secrets"
	// SecretsColumn is the table column denoting the secrets relation/edge.
	SecretsColumn = "account_secrets"
)

// Columns holds all SQL columns for account fields.
var Columns = []string{
	FieldID,
	FieldKind,
	FieldDisplayName,
	FieldSettings,
	FieldNeedsReauth,
	FieldAuthError,
	FieldSyncNotice,
	FieldCreatedAt,
	FieldUpdatedAt,
}

// 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 (
	// DisplayNameValidator is a validator for the "display_name" field. It is called by the builders before save.
	DisplayNameValidator func(string) error
	// DefaultNeedsReauth holds the default value on creation for the "needs_reauth" field.
	DefaultNeedsReauth bool
	// 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
	// IDValidator is a validator for the "id" field. It is called by the builders before save.
	IDValidator func(string) error
)

// Kind defines the type for the "kind" enum field.
type Kind string

// Kind values.
const (
	KindLocal     Kind = "local"
	KindGoogle    Kind = "google"
	KindCaldav    Kind = "caldav"
	KindMicrosoft Kind = "microsoft"
	KindIcal      Kind = "ical"
	KindEvolution Kind = "evolution"
)

func (k Kind) String() string {
	return string(k)
}

// KindValidator is a validator for the "kind" field enum values. It is called by the builders before save.
func KindValidator(k Kind) error {
	switch k {
	case KindLocal, KindGoogle, KindCaldav, KindMicrosoft, KindIcal, KindEvolution:
		return nil
	default:
		return fmt.Errorf("account: invalid enum value for kind field: %q", k)
	}
}

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

// ByKind orders the results by the kind field.
func ByKind(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldKind, opts...).ToFunc()
}

// ByDisplayName orders the results by the display_name field.
func ByDisplayName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDisplayName, opts...).ToFunc()
}

// ByNeedsReauth orders the results by the needs_reauth field.
func ByNeedsReauth(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldNeedsReauth, opts...).ToFunc()
}

// ByAuthError orders the results by the auth_error field.
func ByAuthError(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAuthError, opts...).ToFunc()
}

// BySyncNotice orders the results by the sync_notice field.
func BySyncNotice(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSyncNotice, 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()
}

// ByCalendarsCount orders the results by calendars count.
func ByCalendarsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newCalendarsStep(), opts...)
	}
}

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

// BySecretsCount orders the results by secrets count.
func BySecretsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newSecretsStep(), opts...)
	}
}

// BySecrets orders the results by secrets terms.
func BySecrets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newSecretsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newCalendarsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(CalendarsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, CalendarsTable, CalendarsColumn),
	)
}
func newSecretsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SecretsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, SecretsTable, SecretsColumn),
	)
}
