// Code generated by ent, DO NOT EDIT.

package sopstage

import (
	"time"

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

const (
	// Label holds the string label denoting the sopstage type in the database.
	Label = "sop_stage"
	// 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"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
	FieldDeletedAt = "deleted_at"
	// FieldTaskID holds the string denoting the task_id field in the database.
	FieldTaskID = "task_id"
	// FieldName holds the string denoting the name field in the database.
	FieldName = "name"
	// FieldConditionType holds the string denoting the condition_type field in the database.
	FieldConditionType = "condition_type"
	// FieldConditionOperator holds the string denoting the condition_operator field in the database.
	FieldConditionOperator = "condition_operator"
	// FieldConditionList holds the string denoting the condition_list field in the database.
	FieldConditionList = "condition_list"
	// FieldActionMessage holds the string denoting the action_message field in the database.
	FieldActionMessage = "action_message"
	// FieldActionLabelAdd holds the string denoting the action_label_add field in the database.
	FieldActionLabelAdd = "action_label_add"
	// FieldActionLabelDel holds the string denoting the action_label_del field in the database.
	FieldActionLabelDel = "action_label_del"
	// FieldActionForward holds the string denoting the action_forward field in the database.
	FieldActionForward = "action_forward"
	// FieldIndexSort holds the string denoting the index_sort field in the database.
	FieldIndexSort = "index_sort"
	// EdgeSopTask holds the string denoting the sop_task edge name in mutations.
	EdgeSopTask = "sop_task"
	// EdgeStageNodes holds the string denoting the stage_nodes edge name in mutations.
	EdgeStageNodes = "stage_nodes"
	// EdgeStageMessages holds the string denoting the stage_messages edge name in mutations.
	EdgeStageMessages = "stage_messages"
	// Table holds the table name of the sopstage in the database.
	Table = "sop_stage"
	// SopTaskTable is the table that holds the sop_task relation/edge.
	SopTaskTable = "sop_stage"
	// SopTaskInverseTable is the table name for the SopTask entity.
	// It exists in this package in order to avoid circular dependency with the "soptask" package.
	SopTaskInverseTable = "sop_task"
	// SopTaskColumn is the table column denoting the sop_task relation/edge.
	SopTaskColumn = "task_id"
	// StageNodesTable is the table that holds the stage_nodes relation/edge.
	StageNodesTable = "sop_node"
	// StageNodesInverseTable is the table name for the SopNode entity.
	// It exists in this package in order to avoid circular dependency with the "sopnode" package.
	StageNodesInverseTable = "sop_node"
	// StageNodesColumn is the table column denoting the stage_nodes relation/edge.
	StageNodesColumn = "stage_id"
	// StageMessagesTable is the table that holds the stage_messages relation/edge.
	StageMessagesTable = "message_records"
	// StageMessagesInverseTable is the table name for the MessageRecords entity.
	// It exists in this package in order to avoid circular dependency with the "messagerecords" package.
	StageMessagesInverseTable = "message_records"
	// StageMessagesColumn is the table column denoting the stage_messages relation/edge.
	StageMessagesColumn = "source_id"
)

// Columns holds all SQL columns for sopstage fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldStatus,
	FieldDeletedAt,
	FieldTaskID,
	FieldName,
	FieldConditionType,
	FieldConditionOperator,
	FieldConditionList,
	FieldActionMessage,
	FieldActionLabelAdd,
	FieldActionLabelDel,
	FieldActionForward,
	FieldIndexSort,
}

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

// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
//	import _ "wechat-api/ent/runtime"
var (
	Hooks        [1]ent.Hook
	Interceptors [1]ent.Interceptor
	// 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
	// DefaultStatus holds the default value on creation for the "status" field.
	DefaultStatus uint8
	// DefaultName holds the default value on creation for the "name" field.
	DefaultName string
	// DefaultConditionType holds the default value on creation for the "condition_type" field.
	DefaultConditionType int
	// DefaultConditionOperator holds the default value on creation for the "condition_operator" field.
	DefaultConditionOperator int
	// DefaultIndexSort holds the default value on creation for the "index_sort" field.
	DefaultIndexSort int
)

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

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}

// ByTaskID orders the results by the task_id field.
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTaskID, opts...).ToFunc()
}

// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldName, opts...).ToFunc()
}

// ByConditionType orders the results by the condition_type field.
func ByConditionType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldConditionType, opts...).ToFunc()
}

// ByConditionOperator orders the results by the condition_operator field.
func ByConditionOperator(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldConditionOperator, opts...).ToFunc()
}

// ByIndexSort orders the results by the index_sort field.
func ByIndexSort(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldIndexSort, opts...).ToFunc()
}

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

// ByStageNodesCount orders the results by stage_nodes count.
func ByStageNodesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newStageNodesStep(), opts...)
	}
}

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

// ByStageMessagesCount orders the results by stage_messages count.
func ByStageMessagesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newStageMessagesStep(), opts...)
	}
}

// ByStageMessages orders the results by stage_messages terms.
func ByStageMessages(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newStageMessagesStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newSopTaskStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SopTaskInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, SopTaskTable, SopTaskColumn),
	)
}
func newStageNodesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(StageNodesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, StageNodesTable, StageNodesColumn),
	)
}
func newStageMessagesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(StageMessagesInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, StageMessagesTable, StageMessagesColumn),
	)
}