Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

6.6 KB
Raw Blame
// Code generated by ent, DO NOT EDIT.

package attachment

import (
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
)

const (
	// Label holds the string label denoting the attachment type in the database.
	Label = "attachment"
	// 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"
	// FieldType holds the string denoting the type field in the database.
	FieldType = "type"
	// FieldPrimary holds the string denoting the primary field in the database.
	FieldPrimary = "primary"
	// FieldTitle holds the string denoting the title field in the database.
	FieldTitle = "title"
	// FieldPath holds the string denoting the path field in the database.
	FieldPath = "path"
	// FieldMimeType holds the string denoting the mime_type field in the database.
	FieldMimeType = "mime_type"
	// EdgeEntity holds the string denoting the entity edge name in mutations.
	EdgeEntity = "entity"
	// EdgeThumbnail holds the string denoting the thumbnail edge name in mutations.
	EdgeThumbnail = "thumbnail"
	// Table holds the table name of the attachment in the database.
	Table = "attachments"
	// EntityTable is the table that holds the entity relation/edge.
	EntityTable = "attachments"
	// EntityInverseTable is the table name for the Entity entity.
	// It exists in this package in order to avoid circular dependency with the "entity" package.
	EntityInverseTable = "entities"
	// EntityColumn is the table column denoting the entity relation/edge.
	EntityColumn = "entity_attachments"
	// ThumbnailTable is the table that holds the thumbnail relation/edge.
	ThumbnailTable = "attachments"
	// ThumbnailColumn is the table column denoting the thumbnail relation/edge.
	ThumbnailColumn = "attachment_thumbnail"
)

// Columns holds all SQL columns for attachment fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldType,
	FieldPrimary,
	FieldTitle,
	FieldPath,
	FieldMimeType,
}

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

// 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
}

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
	// DefaultPrimary holds the default value on creation for the "primary" field.
	DefaultPrimary bool
	// DefaultTitle holds the default value on creation for the "title" field.
	DefaultTitle string
	// DefaultPath holds the default value on creation for the "path" field.
	DefaultPath string
	// DefaultMimeType holds the default value on creation for the "mime_type" field.
	DefaultMimeType string
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// Type defines the type for the "type" enum field.
type Type string

// TypeAttachment is the default value of the Type enum.
const DefaultType = TypeAttachment

// Type values.
const (
	TypePhoto      Type = "photo"
	TypeManual     Type = "manual"
	TypeWarranty   Type = "warranty"
	TypeAttachment Type = "attachment"
	TypeReceipt    Type = "receipt"
	TypeThumbnail  Type = "thumbnail"
)

func (_type Type) String() string {
	return string(_type)
}

// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type Type) error {
	switch _type {
	case TypePhoto, TypeManual, TypeWarranty, TypeAttachment, TypeReceipt, TypeThumbnail:
		return nil
	default:
		return fmt.Errorf("attachment: invalid enum value for type field: %q", _type)
	}
}

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

// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldType, opts...).ToFunc()
}

// ByPrimary orders the results by the primary field.
func ByPrimary(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPrimary, opts...).ToFunc()
}

// ByTitle orders the results by the title field.
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTitle, opts...).ToFunc()
}

// ByPath orders the results by the path field.
func ByPath(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPath, opts...).ToFunc()
}

// ByMimeType orders the results by the mime_type field.
func ByMimeType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldMimeType, opts...).ToFunc()
}

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

// ByThumbnailField orders the results by thumbnail field.
func ByThumbnailField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newThumbnailStep(), sql.OrderByField(field, opts...))
	}
}
func newEntityStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(EntityInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, EntityTable, EntityColumn),
	)
}
func newThumbnailStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(Table, FieldID),
		sqlgraph.Edge(sqlgraph.O2O, false, ThumbnailTable, ThumbnailColumn),
	)
}