Skip to content

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

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

package entity

import (
	"time"

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

const (
	// Label holds the string label denoting the entity type in the database.
	Label = "entity"
	// 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"
	// 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"
	// FieldSyncChildEntityLocations holds the string denoting the sync_child_entity_locations field in the database.
	FieldSyncChildEntityLocations = "sync_child_entity_locations"
	// 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"
	// 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"
	// FieldPurchaseDate holds the string denoting the purchase_date field in the database.
	FieldPurchaseDate = "purchase_date"
	// 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"
	// FieldSoldDate holds the string denoting the sold_date field in the database.
	FieldSoldDate = "sold_date"
	// 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"
	// EdgeLocation holds the string denoting the location edge name in mutations.
	EdgeLocation = "location"
	// EdgeLocationEntities holds the string denoting the location_entities edge name in mutations.
	EdgeLocationEntities = "location_entities"
	// EdgeTag holds the string denoting the tag edge name in mutations.
	EdgeTag = "tag"
	// EdgeEntityType holds the string denoting the entity_type edge name in mutations.
	EdgeEntityType = "entity_type"
	// 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"
	// Table holds the table name of the entity in the database.
	Table = "entities"
	// GroupTable is the table that holds the group relation/edge.
	GroupTable = "entities"
	// 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_entities"
	// ParentTable is the table that holds the parent relation/edge.
	ParentTable = "entities"
	// ParentColumn is the table column denoting the parent relation/edge.
	ParentColumn = "entity_children"
	// ChildrenTable is the table that holds the children relation/edge.
	ChildrenTable = "entities"
	// ChildrenColumn is the table column denoting the children relation/edge.
	ChildrenColumn = "entity_children"
	// LocationTable is the table that holds the location relation/edge.
	LocationTable = "entities"
	// LocationColumn is the table column denoting the location relation/edge.
	LocationColumn = "entity_location_entities"
	// LocationEntitiesTable is the table that holds the location_entities relation/edge.
	LocationEntitiesTable = "entities"
	// LocationEntitiesColumn is the table column denoting the location_entities relation/edge.
	LocationEntitiesColumn = "entity_location_entities"
	// TagTable is the table that holds the tag relation/edge. The primary key declared below.
	TagTable = "tag_entities"
	// TagInverseTable is the table name for the Tag entity.
	// It exists in this package in order to avoid circular dependency with the "tag" package.
	TagInverseTable = "tags"
	// EntityTypeTable is the table that holds the entity_type relation/edge.
	EntityTypeTable = "entities"
	// EntityTypeInverseTable is the table name for the EntityType entity.
	// It exists in this package in order to avoid circular dependency with the "entitytype" package.
	EntityTypeInverseTable = "entity_types"
	// EntityTypeColumn is the table column denoting the entity_type relation/edge.
	EntityTypeColumn = "entity_type_entities"
	// FieldsTable is the table that holds the fields relation/edge.
	FieldsTable = "entity_fields"
	// FieldsInverseTable is the table name for the EntityField entity.
	// It exists in this package in order to avoid circular dependency with the "entityfield" package.
	FieldsInverseTable = "entity_fields"
	// FieldsColumn is the table column denoting the fields relation/edge.
	FieldsColumn = "entity_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 = "entity_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 = "entity_attachments"
)

// Columns holds all SQL columns for entity fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldName,
	FieldDescription,
	FieldImportRef,
	FieldNotes,
	FieldQuantity,
	FieldInsured,
	FieldArchived,
	FieldAssetID,
	FieldSyncChildEntityLocations,
	FieldSerialNumber,
	FieldModelNumber,
	FieldManufacturer,
	FieldLifetimeWarranty,
	FieldWarrantyExpires,
	FieldWarrantyDetails,
	FieldPurchaseDate,
	FieldPurchaseFrom,
	FieldPurchasePrice,
	FieldSoldDate,
	FieldSoldTo,
	FieldSoldPrice,
	FieldSoldNotes,
}

// ForeignKeys holds the SQL foreign-keys that are owned by the "entities"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
	"entity_children",
	"entity_location_entities",
	"entity_type_entities",
	"group_entities",
}

var (
	// TagPrimaryKey and TagColumn2 are the table columns denoting the
	// primary key for the tag relation (M2M).
	TagPrimaryKey = []string{"tag_id", "entity_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
	// 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 float64
	// 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 int64
	// DefaultSyncChildEntityLocations holds the default value on creation for the "sync_child_entity_locations" field.
	DefaultSyncChildEntityLocations bool
	// 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
	// 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
	// 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 Entity 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()
}

// BySyncChildEntityLocations orders the results by the sync_child_entity_locations field.
func BySyncChildEntityLocations(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSyncChildEntityLocations, 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()
}

// ByPurchaseDate orders the results by the purchase_date field.
func ByPurchaseDate(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPurchaseDate, 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()
}

// BySoldDate orders the results by the sold_date field.
func BySoldDate(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSoldDate, 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...)...)
	}
}

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

// ByLocationEntitiesCount orders the results by location_entities count.
func ByLocationEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newLocationEntitiesStep(), opts...)
	}
}

// ByLocationEntities orders the results by location_entities terms.
func ByLocationEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newLocationEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByTagCount orders the results by tag count.
func ByTagCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newTagStep(), opts...)
	}
}

// ByTag orders the results by tag terms.
func ByTag(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newTagStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}

// ByEntityTypeField orders the results by entity_type field.
func ByEntityTypeField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newEntityTypeStep(), 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 newLocationStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(Table, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, LocationTable, LocationColumn),
	)
}
func newLocationEntitiesStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(Table, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, LocationEntitiesTable, LocationEntitiesColumn),
	)
}
func newTagStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(TagInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2M, true, TagTable, TagPrimaryKey...),
	)
}
func newEntityTypeStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(EntityTypeInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, EntityTypeTable, EntityTypeColumn),
	)
}
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),
	)
}