collectionnode.go•5.05 kB
// Code generated by ent, DO NOT EDIT.
package collectionnode
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/rs/xid"
)
const (
// Label holds the string label denoting the collectionnode type in the database.
Label = "collection_node"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldCollectionID holds the string denoting the collection_id field in the database.
FieldCollectionID = "collection_id"
// FieldNodeID holds the string denoting the node_id field in the database.
FieldNodeID = "node_id"
// FieldMembershipType holds the string denoting the membership_type field in the database.
FieldMembershipType = "membership_type"
// EdgeCollection holds the string denoting the collection edge name in mutations.
EdgeCollection = "collection"
// EdgeNode holds the string denoting the node edge name in mutations.
EdgeNode = "node"
// CollectionFieldID holds the string denoting the ID field of the Collection.
CollectionFieldID = "id"
// NodeFieldID holds the string denoting the ID field of the Node.
NodeFieldID = "id"
// Table holds the table name of the collectionnode in the database.
Table = "collection_nodes"
// CollectionTable is the table that holds the collection relation/edge.
CollectionTable = "collection_nodes"
// CollectionInverseTable is the table name for the Collection entity.
// It exists in this package in order to avoid circular dependency with the "collection" package.
CollectionInverseTable = "collections"
// CollectionColumn is the table column denoting the collection relation/edge.
CollectionColumn = "collection_id"
// NodeTable is the table that holds the node relation/edge.
NodeTable = "collection_nodes"
// NodeInverseTable is the table name for the Node entity.
// It exists in this package in order to avoid circular dependency with the "node" package.
NodeInverseTable = "nodes"
// NodeColumn is the table column denoting the node relation/edge.
NodeColumn = "node_id"
)
// Columns holds all SQL columns for collectionnode fields.
var Columns = []string{
FieldCreatedAt,
FieldCollectionID,
FieldNodeID,
FieldMembershipType,
}
// 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
// DefaultCollectionID holds the default value on creation for the "collection_id" field.
DefaultCollectionID func() xid.ID
// CollectionIDValidator is a validator for the "collection_id" field. It is called by the builders before save.
CollectionIDValidator func(string) error
// DefaultNodeID holds the default value on creation for the "node_id" field.
DefaultNodeID func() xid.ID
// NodeIDValidator is a validator for the "node_id" field. It is called by the builders before save.
NodeIDValidator func(string) error
// DefaultMembershipType holds the default value on creation for the "membership_type" field.
DefaultMembershipType string
)
// OrderOption defines the ordering options for the CollectionNode queries.
type OrderOption func(*sql.Selector)
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByCollectionID orders the results by the collection_id field.
func ByCollectionID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCollectionID, opts...).ToFunc()
}
// ByNodeID orders the results by the node_id field.
func ByNodeID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNodeID, opts...).ToFunc()
}
// ByMembershipType orders the results by the membership_type field.
func ByMembershipType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMembershipType, opts...).ToFunc()
}
// ByCollectionField orders the results by collection field.
func ByCollectionField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newCollectionStep(), sql.OrderByField(field, opts...))
}
}
// ByNodeField orders the results by node field.
func ByNodeField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newNodeStep(), sql.OrderByField(field, opts...))
}
}
func newCollectionStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, CollectionColumn),
sqlgraph.To(CollectionInverseTable, CollectionFieldID),
sqlgraph.Edge(sqlgraph.M2O, false, CollectionTable, CollectionColumn),
)
}
func newNodeStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, NodeColumn),
sqlgraph.To(NodeInverseTable, NodeFieldID),
sqlgraph.Edge(sqlgraph.M2O, false, NodeTable, NodeColumn),
)
}