// Code generated by ent, DO NOT EDIT.

package messagerecords

import (
	"time"

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

const (
	// Label holds the string label denoting the messagerecords type in the database.
	Label = "message_records"
	// 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"
	// FieldBotWxid holds the string denoting the bot_wxid field in the database.
	FieldBotWxid = "bot_wxid"
	// FieldContactID holds the string denoting the contact_id field in the database.
	FieldContactID = "contact_id"
	// FieldContactType holds the string denoting the contact_type field in the database.
	FieldContactType = "contact_type"
	// FieldContactWxid holds the string denoting the contact_wxid field in the database.
	FieldContactWxid = "contact_wxid"
	// FieldContentType holds the string denoting the content_type field in the database.
	FieldContentType = "content_type"
	// FieldContent holds the string denoting the content field in the database.
	FieldContent = "content"
	// FieldMeta holds the string denoting the meta field in the database.
	FieldMeta = "meta"
	// FieldErrorDetail holds the string denoting the error_detail field in the database.
	FieldErrorDetail = "error_detail"
	// FieldSendTime holds the string denoting the send_time field in the database.
	FieldSendTime = "send_time"
	// FieldSourceType holds the string denoting the source_type field in the database.
	FieldSourceType = "source_type"
	// FieldSourceID holds the string denoting the source_id field in the database.
	FieldSourceID = "source_id"
	// FieldSubSourceID holds the string denoting the sub_source_id field in the database.
	FieldSubSourceID = "sub_source_id"
	// FieldOrganizationID holds the string denoting the organization_id field in the database.
	FieldOrganizationID = "organization_id"
	// EdgeSopStage holds the string denoting the sop_stage edge name in mutations.
	EdgeSopStage = "sop_stage"
	// EdgeSopNode holds the string denoting the sop_node edge name in mutations.
	EdgeSopNode = "sop_node"
	// EdgeMessageContact holds the string denoting the message_contact edge name in mutations.
	EdgeMessageContact = "message_contact"
	// Table holds the table name of the messagerecords in the database.
	Table = "message_records"
	// SopStageTable is the table that holds the sop_stage relation/edge.
	SopStageTable = "message_records"
	// SopStageInverseTable is the table name for the SopStage entity.
	// It exists in this package in order to avoid circular dependency with the "sopstage" package.
	SopStageInverseTable = "sop_stage"
	// SopStageColumn is the table column denoting the sop_stage relation/edge.
	SopStageColumn = "source_id"
	// SopNodeTable is the table that holds the sop_node relation/edge.
	SopNodeTable = "message_records"
	// SopNodeInverseTable is the table name for the SopNode entity.
	// It exists in this package in order to avoid circular dependency with the "sopnode" package.
	SopNodeInverseTable = "sop_node"
	// SopNodeColumn is the table column denoting the sop_node relation/edge.
	SopNodeColumn = "sub_source_id"
	// MessageContactTable is the table that holds the message_contact relation/edge.
	MessageContactTable = "message_records"
	// MessageContactInverseTable is the table name for the Contact entity.
	// It exists in this package in order to avoid circular dependency with the "contact" package.
	MessageContactInverseTable = "contact"
	// MessageContactColumn is the table column denoting the message_contact relation/edge.
	MessageContactColumn = "contact_id"
)

// Columns holds all SQL columns for messagerecords fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldStatus,
	FieldBotWxid,
	FieldContactID,
	FieldContactType,
	FieldContactWxid,
	FieldContentType,
	FieldContent,
	FieldMeta,
	FieldErrorDetail,
	FieldSendTime,
	FieldSourceType,
	FieldSourceID,
	FieldSubSourceID,
	FieldOrganizationID,
}

// 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 (
	// 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
	// DefaultContactType holds the default value on creation for the "contact_type" field.
	DefaultContactType int
	// DefaultContactWxid holds the default value on creation for the "contact_wxid" field.
	DefaultContactWxid string
	// DefaultContentType holds the default value on creation for the "content_type" field.
	DefaultContentType int
	// DefaultContent holds the default value on creation for the "content" field.
	DefaultContent string
	// DefaultErrorDetail holds the default value on creation for the "error_detail" field.
	DefaultErrorDetail string
	// DefaultSourceType holds the default value on creation for the "source_type" field.
	DefaultSourceType int
	// DefaultSourceID holds the default value on creation for the "source_id" field.
	DefaultSourceID uint64
	// DefaultSubSourceID holds the default value on creation for the "sub_source_id" field.
	DefaultSubSourceID uint64
	// DefaultOrganizationID holds the default value on creation for the "organization_id" field.
	DefaultOrganizationID uint64
)

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

// ByBotWxid orders the results by the bot_wxid field.
func ByBotWxid(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldBotWxid, opts...).ToFunc()
}

// ByContactID orders the results by the contact_id field.
func ByContactID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContactID, opts...).ToFunc()
}

// ByContactType orders the results by the contact_type field.
func ByContactType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContactType, opts...).ToFunc()
}

// ByContactWxid orders the results by the contact_wxid field.
func ByContactWxid(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContactWxid, opts...).ToFunc()
}

// ByContentType orders the results by the content_type field.
func ByContentType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContentType, opts...).ToFunc()
}

// ByContent orders the results by the content field.
func ByContent(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldContent, opts...).ToFunc()
}

// ByErrorDetail orders the results by the error_detail field.
func ByErrorDetail(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldErrorDetail, opts...).ToFunc()
}

// BySendTime orders the results by the send_time field.
func BySendTime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSendTime, opts...).ToFunc()
}

// BySourceType orders the results by the source_type field.
func BySourceType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSourceType, opts...).ToFunc()
}

// BySourceID orders the results by the source_id field.
func BySourceID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSourceID, opts...).ToFunc()
}

// BySubSourceID orders the results by the sub_source_id field.
func BySubSourceID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSubSourceID, opts...).ToFunc()
}

// ByOrganizationID orders the results by the organization_id field.
func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
}

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

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

// ByMessageContactField orders the results by message_contact field.
func ByMessageContactField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newMessageContactStep(), sql.OrderByField(field, opts...))
	}
}
func newSopStageStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SopStageInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, SopStageTable, SopStageColumn),
	)
}
func newSopNodeStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(SopNodeInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, SopNodeTable, SopNodeColumn),
	)
}
func newMessageContactStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(MessageContactInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, MessageContactTable, MessageContactColumn),
	)
}
