// Code generated by ent, DO NOT EDIT.

package agentbase

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

const (
	// Label holds the string label denoting the agentbase type in the database.
	Label = "agent_base"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldQ holds the string denoting the q field in the database.
	FieldQ = "q"
	// FieldA holds the string denoting the a field in the database.
	FieldA = "a"
	// FieldChunkIndex holds the string denoting the chunk_index field in the database.
	FieldChunkIndex = "chunk_index"
	// FieldIndexes holds the string denoting the indexes field in the database.
	FieldIndexes = "indexes"
	// FieldDatasetID holds the string denoting the dataset_id field in the database.
	FieldDatasetID = "dataset_id"
	// FieldCollectionID holds the string denoting the collection_id field in the database.
	FieldCollectionID = "collection_id"
	// FieldSourceName holds the string denoting the source_name field in the database.
	FieldSourceName = "source_name"
	// FieldCanWrite holds the string denoting the can_write field in the database.
	FieldCanWrite = "can_write"
	// FieldIsOwner holds the string denoting the is_owner field in the database.
	FieldIsOwner = "is_owner"
	// EdgeWxAgent holds the string denoting the wx_agent edge name in mutations.
	EdgeWxAgent = "wx_agent"
	// Table holds the table name of the agentbase in the database.
	Table = "agent_base"
	// WxAgentTable is the table that holds the wx_agent relation/edge.
	WxAgentTable = "wx"
	// WxAgentInverseTable is the table name for the Wx entity.
	// It exists in this package in order to avoid circular dependency with the "wx" package.
	WxAgentInverseTable = "wx"
	// WxAgentColumn is the table column denoting the wx_agent relation/edge.
	WxAgentColumn = "agent_base_wx_agent"
)

// Columns holds all SQL columns for agentbase fields.
var Columns = []string{
	FieldID,
	FieldQ,
	FieldA,
	FieldChunkIndex,
	FieldIndexes,
	FieldDatasetID,
	FieldCollectionID,
	FieldSourceName,
	FieldCanWrite,
	FieldIsOwner,
}

// 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 (
	// DefaultQ holds the default value on creation for the "q" field.
	DefaultQ string
	// DefaultA holds the default value on creation for the "a" field.
	DefaultA string
	// ChunkIndexValidator is a validator for the "chunk_index" field. It is called by the builders before save.
	ChunkIndexValidator func(uint64) error
	// DefaultDatasetID holds the default value on creation for the "dataset_id" field.
	DefaultDatasetID string
	// DefaultCollectionID holds the default value on creation for the "collection_id" field.
	DefaultCollectionID string
	// DefaultSourceName holds the default value on creation for the "source_name" field.
	DefaultSourceName string
)

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

// ByQ orders the results by the q field.
func ByQ(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldQ, opts...).ToFunc()
}

// ByA orders the results by the a field.
func ByA(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldA, opts...).ToFunc()
}

// ByChunkIndex orders the results by the chunk_index field.
func ByChunkIndex(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldChunkIndex, opts...).ToFunc()
}

// ByDatasetID orders the results by the dataset_id field.
func ByDatasetID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDatasetID, opts...).ToFunc()
}

// ByCollectionID orders the results by the collection_id field.
func ByCollectionID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCollectionID, opts...).ToFunc()
}

// BySourceName orders the results by the source_name field.
func BySourceName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSourceName, opts...).ToFunc()
}

// ByWxAgentCount orders the results by wx_agent count.
func ByWxAgentCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newWxAgentStep(), opts...)
	}
}

// ByWxAgent orders the results by wx_agent terms.
func ByWxAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newWxAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newWxAgentStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(WxAgentInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, WxAgentTable, WxAgentColumn),
	)
}