homebox/backend/internal/data/ent/item/item.go

501 lines
20 KiB
Go
Raw Permalink Normal View History

2022-08-30 18:04:50 +00:00
// Code generated by ent, DO NOT EDIT.
package item
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
2022-08-30 18:04:50 +00:00
"github.com/google/uuid"
)
const (
// Label holds the string label denoting the item type in the database.
Label = "item"
// 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"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldImportRef holds the string denoting the import_ref field in the database.
FieldImportRef = "import_ref"
2022-08-30 18:04:50 +00:00
// FieldNotes holds the string denoting the notes field in the database.
FieldNotes = "notes"
// FieldQuantity holds the string denoting the quantity field in the database.
FieldQuantity = "quantity"
// FieldInsured holds the string denoting the insured field in the database.
FieldInsured = "insured"
// FieldArchived holds the string denoting the archived field in the database.
FieldArchived = "archived"
// FieldAssetID holds the string denoting the asset_id field in the database.
FieldAssetID = "asset_id"
2022-08-30 18:04:50 +00:00
// FieldSerialNumber holds the string denoting the serial_number field in the database.
FieldSerialNumber = "serial_number"
// FieldModelNumber holds the string denoting the model_number field in the database.
FieldModelNumber = "model_number"
// FieldManufacturer holds the string denoting the manufacturer field in the database.
FieldManufacturer = "manufacturer"
2022-09-09 18:20:38 +00:00
// FieldLifetimeWarranty holds the string denoting the lifetime_warranty field in the database.
FieldLifetimeWarranty = "lifetime_warranty"
// FieldWarrantyExpires holds the string denoting the warranty_expires field in the database.
FieldWarrantyExpires = "warranty_expires"
// FieldWarrantyDetails holds the string denoting the warranty_details field in the database.
FieldWarrantyDetails = "warranty_details"
2022-08-30 18:04:50 +00:00
// FieldPurchaseTime holds the string denoting the purchase_time field in the database.
FieldPurchaseTime = "purchase_time"
// FieldPurchaseFrom holds the string denoting the purchase_from field in the database.
FieldPurchaseFrom = "purchase_from"
// FieldPurchasePrice holds the string denoting the purchase_price field in the database.
FieldPurchasePrice = "purchase_price"
// FieldSoldTime holds the string denoting the sold_time field in the database.
FieldSoldTime = "sold_time"
// FieldSoldTo holds the string denoting the sold_to field in the database.
FieldSoldTo = "sold_to"
// FieldSoldPrice holds the string denoting the sold_price field in the database.
FieldSoldPrice = "sold_price"
// FieldSoldNotes holds the string denoting the sold_notes field in the database.
FieldSoldNotes = "sold_notes"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// EdgeParent holds the string denoting the parent edge name in mutations.
EdgeParent = "parent"
// EdgeChildren holds the string denoting the children edge name in mutations.
EdgeChildren = "children"
// EdgeLabel holds the string denoting the label edge name in mutations.
EdgeLabel = "label"
2022-08-30 18:04:50 +00:00
// EdgeLocation holds the string denoting the location edge name in mutations.
EdgeLocation = "location"
// EdgeFields holds the string denoting the fields edge name in mutations.
EdgeFields = "fields"
// EdgeMaintenanceEntries holds the string denoting the maintenance_entries edge name in mutations.
EdgeMaintenanceEntries = "maintenance_entries"
// EdgeAttachments holds the string denoting the attachments edge name in mutations.
EdgeAttachments = "attachments"
2022-08-30 18:04:50 +00:00
// Table holds the table name of the item in the database.
Table = "items"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "items"
// GroupInverseTable is the table name for the Group entity.
// It exists in this package in order to avoid circular dependency with the "group" package.
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
GroupColumn = "group_items"
// ParentTable is the table that holds the parent relation/edge.
ParentTable = "items"
// ParentColumn is the table column denoting the parent relation/edge.
ParentColumn = "item_children"
// ChildrenTable is the table that holds the children relation/edge.
ChildrenTable = "items"
// ChildrenColumn is the table column denoting the children relation/edge.
ChildrenColumn = "item_children"
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
LabelTable = "label_items"
// LabelInverseTable is the table name for the Label entity.
// It exists in this package in order to avoid circular dependency with the "label" package.
LabelInverseTable = "labels"
2022-08-30 18:04:50 +00:00
// LocationTable is the table that holds the location relation/edge.
LocationTable = "items"
// LocationInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationInverseTable = "locations"
// LocationColumn is the table column denoting the location relation/edge.
LocationColumn = "location_items"
// FieldsTable is the table that holds the fields relation/edge.
FieldsTable = "item_fields"
// FieldsInverseTable is the table name for the ItemField entity.
// It exists in this package in order to avoid circular dependency with the "itemfield" package.
FieldsInverseTable = "item_fields"
// FieldsColumn is the table column denoting the fields relation/edge.
FieldsColumn = "item_fields"
// MaintenanceEntriesTable is the table that holds the maintenance_entries relation/edge.
MaintenanceEntriesTable = "maintenance_entries"
// MaintenanceEntriesInverseTable is the table name for the MaintenanceEntry entity.
// It exists in this package in order to avoid circular dependency with the "maintenanceentry" package.
MaintenanceEntriesInverseTable = "maintenance_entries"
// MaintenanceEntriesColumn is the table column denoting the maintenance_entries relation/edge.
MaintenanceEntriesColumn = "item_id"
// AttachmentsTable is the table that holds the attachments relation/edge.
AttachmentsTable = "attachments"
// AttachmentsInverseTable is the table name for the Attachment entity.
// It exists in this package in order to avoid circular dependency with the "attachment" package.
AttachmentsInverseTable = "attachments"
// AttachmentsColumn is the table column denoting the attachments relation/edge.
AttachmentsColumn = "item_attachments"
2022-08-30 18:04:50 +00:00
)
// Columns holds all SQL columns for item fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldName,
FieldDescription,
FieldImportRef,
2022-08-30 18:04:50 +00:00
FieldNotes,
FieldQuantity,
FieldInsured,
FieldArchived,
FieldAssetID,
2022-08-30 18:04:50 +00:00
FieldSerialNumber,
FieldModelNumber,
FieldManufacturer,
2022-09-09 18:20:38 +00:00
FieldLifetimeWarranty,
FieldWarrantyExpires,
FieldWarrantyDetails,
2022-08-30 18:04:50 +00:00
FieldPurchaseTime,
FieldPurchaseFrom,
FieldPurchasePrice,
FieldSoldTime,
FieldSoldTo,
FieldSoldPrice,
FieldSoldNotes,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "items"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"group_items",
"item_children",
2022-08-30 18:04:50 +00:00
"location_items",
}
var (
// LabelPrimaryKey and LabelColumn2 are the table columns denoting the
// primary key for the label relation (M2M).
LabelPrimaryKey = []string{"label_id", "item_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
}
}
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
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
DescriptionValidator func(string) error
// ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
ImportRefValidator func(string) error
2022-08-30 18:04:50 +00:00
// NotesValidator is a validator for the "notes" field. It is called by the builders before save.
NotesValidator func(string) error
// DefaultQuantity holds the default value on creation for the "quantity" field.
DefaultQuantity int
// DefaultInsured holds the default value on creation for the "insured" field.
DefaultInsured bool
// DefaultArchived holds the default value on creation for the "archived" field.
DefaultArchived bool
// DefaultAssetID holds the default value on creation for the "asset_id" field.
DefaultAssetID int
2022-08-30 18:04:50 +00:00
// SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
SerialNumberValidator func(string) error
// ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
ModelNumberValidator func(string) error
// ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
ManufacturerValidator func(string) error
2022-09-09 18:20:38 +00:00
// DefaultLifetimeWarranty holds the default value on creation for the "lifetime_warranty" field.
DefaultLifetimeWarranty bool
// WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
WarrantyDetailsValidator func(string) error
2022-08-30 18:04:50 +00:00
// DefaultPurchasePrice holds the default value on creation for the "purchase_price" field.
DefaultPurchasePrice float64
// DefaultSoldPrice holds the default value on creation for the "sold_price" field.
DefaultSoldPrice float64
// SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
SoldNotesValidator 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 Item 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()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByImportRef orders the results by the import_ref field.
func ByImportRef(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldImportRef, opts...).ToFunc()
}
// ByNotes orders the results by the notes field.
func ByNotes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldNotes, opts...).ToFunc()
}
// ByQuantity orders the results by the quantity field.
func ByQuantity(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldQuantity, opts...).ToFunc()
}
// ByInsured orders the results by the insured field.
func ByInsured(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldInsured, opts...).ToFunc()
}
// ByArchived orders the results by the archived field.
func ByArchived(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldArchived, opts...).ToFunc()
}
// ByAssetID orders the results by the asset_id field.
func ByAssetID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAssetID, opts...).ToFunc()
}
// BySerialNumber orders the results by the serial_number field.
func BySerialNumber(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSerialNumber, opts...).ToFunc()
}
// ByModelNumber orders the results by the model_number field.
func ByModelNumber(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModelNumber, opts...).ToFunc()
}
// ByManufacturer orders the results by the manufacturer field.
func ByManufacturer(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldManufacturer, opts...).ToFunc()
}
// ByLifetimeWarranty orders the results by the lifetime_warranty field.
func ByLifetimeWarranty(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLifetimeWarranty, opts...).ToFunc()
}
// ByWarrantyExpires orders the results by the warranty_expires field.
func ByWarrantyExpires(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWarrantyExpires, opts...).ToFunc()
}
// ByWarrantyDetails orders the results by the warranty_details field.
func ByWarrantyDetails(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldWarrantyDetails, opts...).ToFunc()
}
// ByPurchaseTime orders the results by the purchase_time field.
func ByPurchaseTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPurchaseTime, opts...).ToFunc()
}
// ByPurchaseFrom orders the results by the purchase_from field.
func ByPurchaseFrom(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPurchaseFrom, opts...).ToFunc()
}
// ByPurchasePrice orders the results by the purchase_price field.
func ByPurchasePrice(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPurchasePrice, opts...).ToFunc()
}
// BySoldTime orders the results by the sold_time field.
func BySoldTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoldTime, opts...).ToFunc()
}
// BySoldTo orders the results by the sold_to field.
func BySoldTo(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoldTo, opts...).ToFunc()
}
// BySoldPrice orders the results by the sold_price field.
func BySoldPrice(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoldPrice, opts...).ToFunc()
}
// BySoldNotes orders the results by the sold_notes field.
func BySoldNotes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSoldNotes, opts...).ToFunc()
}
// ByGroupField orders the results by group field.
func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGroupStep(), 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...))
}
}
// ByChildrenCount orders the results by children count.
func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...)
}
}
// ByChildren orders the results by children terms.
func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByLabelCount orders the results by label count.
func ByLabelCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newLabelStep(), opts...)
}
}
// ByLabel orders the results by label terms.
func ByLabel(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLabelStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByLocationField orders the results by location field.
func ByLocationField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLocationStep(), sql.OrderByField(field, opts...))
}
}
// ByFieldsCount orders the results by fields count.
func ByFieldsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newFieldsStep(), opts...)
}
}
// ByFields orders the results by fields terms.
func ByFields(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newFieldsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByMaintenanceEntriesCount orders the results by maintenance_entries count.
func ByMaintenanceEntriesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newMaintenanceEntriesStep(), opts...)
}
}
// ByMaintenanceEntries orders the results by maintenance_entries terms.
func ByMaintenanceEntries(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newMaintenanceEntriesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByAttachmentsCount orders the results by attachments count.
func ByAttachmentsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAttachmentsStep(), opts...)
}
}
// ByAttachments orders the results by attachments terms.
func ByAttachments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAttachmentsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newGroupStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
)
}
func newParentStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn),
)
}
func newChildrenStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
)
}
func newLabelStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LabelInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
)
}
func newLocationStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LocationInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, LocationTable, LocationColumn),
)
}
func newFieldsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(FieldsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, FieldsTable, FieldsColumn),
)
}
func newMaintenanceEntriesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(MaintenanceEntriesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, MaintenanceEntriesTable, MaintenanceEntriesColumn),
)
}
func newAttachmentsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AttachmentsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AttachmentsTable, AttachmentsColumn),
)
}