99 lines
3.0 KiB
Go
99 lines
3.0 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package link
|
|
|
|
import (
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const (
|
|
// Label holds the string label denoting the link type in the database.
|
|
Label = "link"
|
|
// FieldID holds the string denoting the id field in the database.
|
|
FieldID = "id"
|
|
// FieldKey holds the string denoting the key field in the database.
|
|
FieldKey = "key"
|
|
// FieldOriginalURL holds the string denoting the original_url field in the database.
|
|
FieldOriginalURL = "original_url"
|
|
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
|
EdgeOwner = "owner"
|
|
// Table holds the table name of the link in the database.
|
|
Table = "links"
|
|
// OwnerTable is the table that holds the owner relation/edge. The primary key declared below.
|
|
OwnerTable = "user_links"
|
|
// OwnerInverseTable is the table name for the User entity.
|
|
// It exists in this package in order to avoid circular dependency with the "user" package.
|
|
OwnerInverseTable = "users"
|
|
)
|
|
|
|
// Columns holds all SQL columns for link fields.
|
|
var Columns = []string{
|
|
FieldID,
|
|
FieldKey,
|
|
FieldOriginalURL,
|
|
}
|
|
|
|
var (
|
|
// OwnerPrimaryKey and OwnerColumn2 are the table columns denoting the
|
|
// primary key for the owner relation (M2M).
|
|
OwnerPrimaryKey = []string{"user_id", "link_id"}
|
|
)
|
|
|
|
// 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 (
|
|
// OriginalURLValidator is a validator for the "original_url" field. It is called by the builders before save.
|
|
OriginalURLValidator func(string) error
|
|
// DefaultID holds the default value on creation for the "id" field.
|
|
DefaultID func() uuid.UUID
|
|
)
|
|
|
|
// OrderOption defines the ordering options for the Link 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()
|
|
}
|
|
|
|
// ByKey orders the results by the key field.
|
|
func ByKey(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldKey, opts...).ToFunc()
|
|
}
|
|
|
|
// ByOriginalURL orders the results by the original_url field.
|
|
func ByOriginalURL(opts ...sql.OrderTermOption) OrderOption {
|
|
return sql.OrderByField(FieldOriginalURL, opts...).ToFunc()
|
|
}
|
|
|
|
// ByOwnerCount orders the results by owner count.
|
|
func ByOwnerCount(opts ...sql.OrderTermOption) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborsCount(s, newOwnerStep(), opts...)
|
|
}
|
|
}
|
|
|
|
// ByOwner orders the results by owner terms.
|
|
func ByOwner(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
|
return func(s *sql.Selector) {
|
|
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), append([]sql.OrderTerm{term}, terms...)...)
|
|
}
|
|
}
|
|
func newOwnerStep() *sqlgraph.Step {
|
|
return sqlgraph.NewStep(
|
|
sqlgraph.From(Table, FieldID),
|
|
sqlgraph.To(OwnerInverseTable, FieldID),
|
|
sqlgraph.Edge(sqlgraph.M2M, true, OwnerTable, OwnerPrimaryKey...),
|
|
)
|
|
}
|