asset.go•11.4 kB
// Code generated by ent, DO NOT EDIT.
package asset
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 asset type in the database.
Label = "asset"
// 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"
// FieldFilename holds the string denoting the filename field in the database.
FieldFilename = "filename"
// FieldSize holds the string denoting the size field in the database.
FieldSize = "size"
// FieldMimeType holds the string denoting the mime_type field in the database.
FieldMimeType = "mime_type"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldParentAssetID holds the string denoting the parent_asset_id field in the database.
FieldParentAssetID = "parent_asset_id"
// EdgePosts holds the string denoting the posts edge name in mutations.
EdgePosts = "posts"
// EdgeNodes holds the string denoting the nodes edge name in mutations.
EdgeNodes = "nodes"
// EdgeLinks holds the string denoting the links edge name in mutations.
EdgeLinks = "links"
// EdgeOwner holds the string denoting the owner edge name in mutations.
EdgeOwner = "owner"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeAssets holds the string denoting the assets edge name in mutations.
EdgeAssets = "assets"
// EdgeEvent holds the string denoting the event edge name in mutations.
EdgeEvent = "event"
// Table holds the table name of the asset in the database.
Table = "assets"
// PostsTable is the table that holds the posts relation/edge. The primary key declared below.
PostsTable = "post_assets"
// PostsInverseTable is the table name for the Post entity.
// It exists in this package in order to avoid circular dependency with the "post" package.
PostsInverseTable = "posts"
// NodesTable is the table that holds the nodes relation/edge. The primary key declared below.
NodesTable = "node_assets"
// NodesInverseTable is the table name for the Node entity.
// It exists in this package in order to avoid circular dependency with the "node" package.
NodesInverseTable = "nodes"
// LinksTable is the table that holds the links relation/edge. The primary key declared below.
LinksTable = "link_assets"
// LinksInverseTable is the table name for the Link entity.
// It exists in this package in order to avoid circular dependency with the "link" package.
LinksInverseTable = "links"
// OwnerTable is the table that holds the owner relation/edge.
OwnerTable = "assets"
// OwnerInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
OwnerInverseTable = "accounts"
// OwnerColumn is the table column denoting the owner relation/edge.
OwnerColumn = "account_id"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "assets"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "parent_asset_id"
// AssetsTable is the table that holds the assets relation/edge.
AssetsTable = "assets"
// AssetsColumn is the table column denoting the assets relation/edge.
AssetsColumn = "parent_asset_id"
// EventTable is the table that holds the event relation/edge.
EventTable = "events"
// EventInverseTable is the table name for the Event entity.
// It exists in this package in order to avoid circular dependency with the "event" package.
EventInverseTable = "events"
// EventColumn is the table column denoting the event relation/edge.
EventColumn = "asset_event"
)
// Columns holds all SQL columns for asset fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldFilename,
FieldSize,
FieldMimeType,
FieldMetadata,
FieldAccountID,
FieldParentAssetID,
}
var (
// PostsPrimaryKey and PostsColumn2 are the table columns denoting the
// primary key for the posts relation (M2M).
PostsPrimaryKey = []string{"post_id", "asset_id"}
// NodesPrimaryKey and NodesColumn2 are the table columns denoting the
// primary key for the nodes relation (M2M).
NodesPrimaryKey = []string{"node_id", "asset_id"}
// LinksPrimaryKey and LinksColumn2 are the table columns denoting the
// primary key for the links relation (M2M).
LinksPrimaryKey = []string{"link_id", "asset_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 (
// 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
// DefaultID holds the default value on creation for the "id" field.
DefaultID func() xid.ID
// IDValidator is a validator for the "id" field. It is called by the builders before save.
IDValidator func(string) error
)
// OrderOption defines the ordering options for the Asset 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()
}
// ByFilename orders the results by the filename field.
func ByFilename(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldFilename, opts...).ToFunc()
}
// BySize orders the results by the size field.
func BySize(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSize, opts...).ToFunc()
}
// ByMimeType orders the results by the mime_type field.
func ByMimeType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMimeType, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByParentAssetID orders the results by the parent_asset_id field.
func ByParentAssetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldParentAssetID, opts...).ToFunc()
}
// ByPostsCount orders the results by posts count.
func ByPostsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newPostsStep(), opts...)
}
}
// ByPosts orders the results by posts terms.
func ByPosts(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPostsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByNodesCount orders the results by nodes count.
func ByNodesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newNodesStep(), opts...)
}
}
// ByNodes orders the results by nodes terms.
func ByNodes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newNodesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByLinksCount orders the results by links count.
func ByLinksCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newLinksStep(), opts...)
}
}
// ByLinks orders the results by links terms.
func ByLinks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLinksStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByOwnerField orders the results by owner field.
func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...))
}
}
// ByParentField orders the results by parent field.
func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...))
}
}
// ByAssetsCount orders the results by assets count.
func ByAssetsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAssetsStep(), opts...)
}
}
// ByAssets orders the results by assets terms.
func ByAssets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAssetsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByEventCount orders the results by event count.
func ByEventCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEventStep(), opts...)
}
}
// ByEvent orders the results by event terms.
func ByEvent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEventStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newPostsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(PostsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, PostsTable, PostsPrimaryKey...),
)
}
func newNodesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(NodesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, NodesTable, NodesPrimaryKey...),
)
}
func newLinksStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LinksInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, LinksTable, LinksPrimaryKey...),
)
}
func newOwnerStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(OwnerInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newAssetsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AssetsTable, AssetsColumn),
)
}
func newEventStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EventInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EventTable, EventColumn),
)
}