2022-09-12 22:47:27 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package attachment
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2023-07-23 03:57:51 +00:00
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
2022-09-12 22:47:27 +00:00
|
|
|
"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"
|
2023-10-07 02:51:08 +00:00
|
|
|
// FieldPrimary holds the string denoting the primary field in the database.
|
|
|
|
FieldPrimary = "primary"
|
2022-09-12 22:47:27 +00:00
|
|
|
// EdgeItem holds the string denoting the item edge name in mutations.
|
|
|
|
EdgeItem = "item"
|
|
|
|
// EdgeDocument holds the string denoting the document edge name in mutations.
|
|
|
|
EdgeDocument = "document"
|
|
|
|
// Table holds the table name of the attachment in the database.
|
|
|
|
Table = "attachments"
|
|
|
|
// ItemTable is the table that holds the item relation/edge.
|
|
|
|
ItemTable = "attachments"
|
|
|
|
// ItemInverseTable is the table name for the Item entity.
|
|
|
|
// It exists in this package in order to avoid circular dependency with the "item" package.
|
|
|
|
ItemInverseTable = "items"
|
|
|
|
// ItemColumn is the table column denoting the item relation/edge.
|
|
|
|
ItemColumn = "item_attachments"
|
|
|
|
// DocumentTable is the table that holds the document relation/edge.
|
|
|
|
DocumentTable = "attachments"
|
|
|
|
// DocumentInverseTable is the table name for the Document entity.
|
|
|
|
// It exists in this package in order to avoid circular dependency with the "document" package.
|
|
|
|
DocumentInverseTable = "documents"
|
|
|
|
// DocumentColumn is the table column denoting the document relation/edge.
|
|
|
|
DocumentColumn = "document_attachments"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Columns holds all SQL columns for attachment fields.
|
|
|
|
var Columns = []string{
|
|
|
|
FieldID,
|
|
|
|
FieldCreatedAt,
|
|
|
|
FieldUpdatedAt,
|
|
|
|
FieldType,
|
2023-10-07 02:51:08 +00:00
|
|
|
FieldPrimary,
|
2022-09-12 22:47:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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{
|
|
|
|
"document_attachments",
|
|
|
|
"item_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
|
2023-10-07 02:51:08 +00:00
|
|
|
// DefaultPrimary holds the default value on creation for the "primary" field.
|
|
|
|
DefaultPrimary bool
|
2022-09-12 22:47:27 +00:00
|
|
|
// 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"
|
2022-10-16 03:45:36 +00:00
|
|
|
TypeReceipt Type = "receipt"
|
2022-09-12 22:47:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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 {
|
2022-10-16 03:45:36 +00:00
|
|
|
case TypePhoto, TypeManual, TypeWarranty, TypeAttachment, TypeReceipt:
|
2022-09-12 22:47:27 +00:00
|
|
|
return nil
|
|
|
|
default:
|
|
|
|
return fmt.Errorf("attachment: invalid enum value for type field: %q", _type)
|
|
|
|
}
|
|
|
|
}
|
2023-07-23 03:57:51 +00:00
|
|
|
|
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
|
2023-10-07 02:51:08 +00:00
|
|
|
// ByPrimary orders the results by the primary field.
|
|
|
|
func ByPrimary(opts ...sql.OrderTermOption) OrderOption {
|
|
|
|
return sql.OrderByField(FieldPrimary, opts...).ToFunc()
|
|
|
|
}
|
|
|
|
|
2023-07-23 03:57:51 +00:00
|
|
|
// ByItemField orders the results by item field.
|
|
|
|
func ByItemField(field string, opts ...sql.OrderTermOption) OrderOption {
|
|
|
|
return func(s *sql.Selector) {
|
|
|
|
sqlgraph.OrderByNeighborTerms(s, newItemStep(), sql.OrderByField(field, opts...))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ByDocumentField orders the results by document field.
|
|
|
|
func ByDocumentField(field string, opts ...sql.OrderTermOption) OrderOption {
|
|
|
|
return func(s *sql.Selector) {
|
|
|
|
sqlgraph.OrderByNeighborTerms(s, newDocumentStep(), sql.OrderByField(field, opts...))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func newItemStep() *sqlgraph.Step {
|
|
|
|
return sqlgraph.NewStep(
|
|
|
|
sqlgraph.From(Table, FieldID),
|
|
|
|
sqlgraph.To(ItemInverseTable, FieldID),
|
|
|
|
sqlgraph.Edge(sqlgraph.M2O, true, ItemTable, ItemColumn),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
func newDocumentStep() *sqlgraph.Step {
|
|
|
|
return sqlgraph.NewStep(
|
|
|
|
sqlgraph.From(Table, FieldID),
|
|
|
|
sqlgraph.To(DocumentInverseTable, FieldID),
|
|
|
|
sqlgraph.Edge(sqlgraph.M2O, true, DocumentTable, DocumentColumn),
|
|
|
|
)
|
|
|
|
}
|