// Code generated by ent, DO NOT EDIT.

package packagemetrics

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

const (
	// Label holds the string label denoting the packagemetrics type in the database.
	Label = "package_metrics"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldPackagesLoaded holds the string denoting the packages_loaded field in the database.
	FieldPackagesLoaded = "packages_loaded"
	// EdgeMetrics holds the string denoting the metrics edge name in mutations.
	EdgeMetrics = "metrics"
	// EdgePackageLoadMetrics holds the string denoting the package_load_metrics edge name in mutations.
	EdgePackageLoadMetrics = "package_load_metrics"
	// Table holds the table name of the packagemetrics in the database.
	Table = "package_metrics"
	// MetricsTable is the table that holds the metrics relation/edge.
	MetricsTable = "package_metrics"
	// MetricsInverseTable is the table name for the Metrics entity.
	// It exists in this package in order to avoid circular dependency with the "metrics" package.
	MetricsInverseTable = "metrics"
	// MetricsColumn is the table column denoting the metrics relation/edge.
	MetricsColumn = "metrics_package_metrics"
	// PackageLoadMetricsTable is the table that holds the package_load_metrics relation/edge.
	PackageLoadMetricsTable = "package_load_metrics"
	// PackageLoadMetricsInverseTable is the table name for the PackageLoadMetrics entity.
	// It exists in this package in order to avoid circular dependency with the "packageloadmetrics" package.
	PackageLoadMetricsInverseTable = "package_load_metrics"
	// PackageLoadMetricsColumn is the table column denoting the package_load_metrics relation/edge.
	PackageLoadMetricsColumn = "package_metrics_package_load_metrics"
)

// Columns holds all SQL columns for packagemetrics fields.
var Columns = []string{
	FieldID,
	FieldPackagesLoaded,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "package_metrics"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"metrics_package_metrics",
}

// 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
		}
	}
	for i := range ForeignKeys {
		if column == ForeignKeys[i] {
			return true
		}
	}
	return false
}

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

// ByPackagesLoaded orders the results by the packages_loaded field.
func ByPackagesLoaded(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPackagesLoaded, opts...).ToFunc()
}

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

// ByPackageLoadMetricsCount orders the results by package_load_metrics count.
func ByPackageLoadMetricsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newPackageLoadMetricsStep(), opts...)
	}
}

// ByPackageLoadMetrics orders the results by package_load_metrics terms.
func ByPackageLoadMetrics(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newPackageLoadMetricsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newMetricsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(MetricsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, true, MetricsTable, MetricsColumn),
	)
}
func newPackageLoadMetricsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(PackageLoadMetricsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, PackageLoadMetricsTable, PackageLoadMetricsColumn),
	)
}
