mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2026-01-01 18:47:20 +01:00
* ent re-generation
* add oidc integration
* document oidc integration
* go fmt
* address backend linter findings
* run prettier on index.vue
* State cookie domain can mismatch when Hostname override is used (breaks CSRF check). Add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Delete state cookie with matching domain and MaxAge; add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix endpoint path in comments and error to include /api/v1.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Also use request context when verifying the ID token.
* Do not return raw auth errors to clients (user-enumeration risk).
* consistently set cookie the same way across function
* remove baseURL after declaration
* only enable OIDC routes if OIDC is enabled
* swagger doc for failure
* Only block when provider=local; move the check after parsing provider
* fix extended session comment
* reduce pii logging
* futher reduce pii logging
* remove unused DiscoveryDocument
* remove unused offline_access from default oidc scopes
* remove offline access from AuthCodeURL
* support host from X-Forwarded-Host
* set sane default claim names if unset
* error strings should not be capitalized
* Revert "run prettier on index.vue"
This reverts commit aa22330a23.
* Add timeout to provider discovery
* Split scopes robustly
* refactor hostname calculation
* address frontend prettier findings
* add property oidc on type APISummary
* LoginOIDC: Normalize inputs, only create if not found
* add oidc email verification
* oidc handleCallback: clear state cookie before each return
* add support for oidc nonce parameter
* Harden first-login race: handle concurrent creates gracefully and fix log key.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* support email verified claim as bool or string
* fail fast on empty email
* PKCE verifier
* fix: add timing delay to attachment test to resolve CI race condition
The attachment test was failing intermittently in CI due to a race condition
between attachment creation and retrieval. Adding a small 100ms delay after
attachment creation ensures the file system and database operations complete
before the test attempts to verify the attachment exists.
* Revert "fix: add timing delay to attachment test to resolve CI race condition"
This reverts commit 4aa8b2a0d829753e8d2dd1ba76f4b1e04e28c45e.
* oidc error state, use ref
* rename oidc.force to oidc.authRedirect
* remove hardcoded oidc error timeout
* feat: sub/iss based identity matching and userinfo endpoint collection
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
543 lines
20 KiB
Go
Generated
543 lines
20 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
|
)
|
|
|
|
// Item is the model entity for the Item schema.
|
|
type Item struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// UpdatedAt holds the value of the "updated_at" field.
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description string `json:"description,omitempty"`
|
|
// ImportRef holds the value of the "import_ref" field.
|
|
ImportRef string `json:"import_ref,omitempty"`
|
|
// Notes holds the value of the "notes" field.
|
|
Notes string `json:"notes,omitempty"`
|
|
// Quantity holds the value of the "quantity" field.
|
|
Quantity int `json:"quantity,omitempty"`
|
|
// Insured holds the value of the "insured" field.
|
|
Insured bool `json:"insured,omitempty"`
|
|
// Archived holds the value of the "archived" field.
|
|
Archived bool `json:"archived,omitempty"`
|
|
// AssetID holds the value of the "asset_id" field.
|
|
AssetID int `json:"asset_id,omitempty"`
|
|
// SyncChildItemsLocations holds the value of the "sync_child_items_locations" field.
|
|
SyncChildItemsLocations bool `json:"sync_child_items_locations,omitempty"`
|
|
// SerialNumber holds the value of the "serial_number" field.
|
|
SerialNumber string `json:"serial_number,omitempty"`
|
|
// ModelNumber holds the value of the "model_number" field.
|
|
ModelNumber string `json:"model_number,omitempty"`
|
|
// Manufacturer holds the value of the "manufacturer" field.
|
|
Manufacturer string `json:"manufacturer,omitempty"`
|
|
// LifetimeWarranty holds the value of the "lifetime_warranty" field.
|
|
LifetimeWarranty bool `json:"lifetime_warranty,omitempty"`
|
|
// WarrantyExpires holds the value of the "warranty_expires" field.
|
|
WarrantyExpires time.Time `json:"warranty_expires,omitempty"`
|
|
// WarrantyDetails holds the value of the "warranty_details" field.
|
|
WarrantyDetails string `json:"warranty_details,omitempty"`
|
|
// PurchaseTime holds the value of the "purchase_time" field.
|
|
PurchaseTime time.Time `json:"purchase_time,omitempty"`
|
|
// PurchaseFrom holds the value of the "purchase_from" field.
|
|
PurchaseFrom string `json:"purchase_from,omitempty"`
|
|
// PurchasePrice holds the value of the "purchase_price" field.
|
|
PurchasePrice float64 `json:"purchase_price,omitempty"`
|
|
// SoldTime holds the value of the "sold_time" field.
|
|
SoldTime time.Time `json:"sold_time,omitempty"`
|
|
// SoldTo holds the value of the "sold_to" field.
|
|
SoldTo string `json:"sold_to,omitempty"`
|
|
// SoldPrice holds the value of the "sold_price" field.
|
|
SoldPrice float64 `json:"sold_price,omitempty"`
|
|
// SoldNotes holds the value of the "sold_notes" field.
|
|
SoldNotes string `json:"sold_notes,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the ItemQuery when eager-loading is set.
|
|
Edges ItemEdges `json:"edges"`
|
|
group_items *uuid.UUID
|
|
item_children *uuid.UUID
|
|
location_items *uuid.UUID
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// ItemEdges holds the relations/edges for other nodes in the graph.
|
|
type ItemEdges struct {
|
|
// Group holds the value of the group edge.
|
|
Group *Group `json:"group,omitempty"`
|
|
// Parent holds the value of the parent edge.
|
|
Parent *Item `json:"parent,omitempty"`
|
|
// Children holds the value of the children edge.
|
|
Children []*Item `json:"children,omitempty"`
|
|
// Label holds the value of the label edge.
|
|
Label []*Label `json:"label,omitempty"`
|
|
// Location holds the value of the location edge.
|
|
Location *Location `json:"location,omitempty"`
|
|
// Fields holds the value of the fields edge.
|
|
Fields []*ItemField `json:"fields,omitempty"`
|
|
// MaintenanceEntries holds the value of the maintenance_entries edge.
|
|
MaintenanceEntries []*MaintenanceEntry `json:"maintenance_entries,omitempty"`
|
|
// Attachments holds the value of the attachments edge.
|
|
Attachments []*Attachment `json:"attachments,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [8]bool
|
|
}
|
|
|
|
// GroupOrErr returns the Group value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e ItemEdges) GroupOrErr() (*Group, error) {
|
|
if e.Group != nil {
|
|
return e.Group, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: group.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "group"}
|
|
}
|
|
|
|
// ParentOrErr returns the Parent value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e ItemEdges) ParentOrErr() (*Item, error) {
|
|
if e.Parent != nil {
|
|
return e.Parent, nil
|
|
} else if e.loadedTypes[1] {
|
|
return nil, &NotFoundError{label: item.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "parent"}
|
|
}
|
|
|
|
// ChildrenOrErr returns the Children value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ItemEdges) ChildrenOrErr() ([]*Item, error) {
|
|
if e.loadedTypes[2] {
|
|
return e.Children, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "children"}
|
|
}
|
|
|
|
// LabelOrErr returns the Label value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
|
|
if e.loadedTypes[3] {
|
|
return e.Label, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "label"}
|
|
}
|
|
|
|
// LocationOrErr returns the Location value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e ItemEdges) LocationOrErr() (*Location, error) {
|
|
if e.Location != nil {
|
|
return e.Location, nil
|
|
} else if e.loadedTypes[4] {
|
|
return nil, &NotFoundError{label: location.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "location"}
|
|
}
|
|
|
|
// FieldsOrErr returns the Fields value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) {
|
|
if e.loadedTypes[5] {
|
|
return e.Fields, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "fields"}
|
|
}
|
|
|
|
// MaintenanceEntriesOrErr returns the MaintenanceEntries value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ItemEdges) MaintenanceEntriesOrErr() ([]*MaintenanceEntry, error) {
|
|
if e.loadedTypes[6] {
|
|
return e.MaintenanceEntries, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "maintenance_entries"}
|
|
}
|
|
|
|
// AttachmentsOrErr returns the Attachments value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e ItemEdges) AttachmentsOrErr() ([]*Attachment, error) {
|
|
if e.loadedTypes[7] {
|
|
return e.Attachments, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "attachments"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Item) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case item.FieldInsured, item.FieldArchived, item.FieldSyncChildItemsLocations, item.FieldLifetimeWarranty:
|
|
values[i] = new(sql.NullBool)
|
|
case item.FieldPurchasePrice, item.FieldSoldPrice:
|
|
values[i] = new(sql.NullFloat64)
|
|
case item.FieldQuantity, item.FieldAssetID:
|
|
values[i] = new(sql.NullInt64)
|
|
case item.FieldName, item.FieldDescription, item.FieldImportRef, item.FieldNotes, item.FieldSerialNumber, item.FieldModelNumber, item.FieldManufacturer, item.FieldWarrantyDetails, item.FieldPurchaseFrom, item.FieldSoldTo, item.FieldSoldNotes:
|
|
values[i] = new(sql.NullString)
|
|
case item.FieldCreatedAt, item.FieldUpdatedAt, item.FieldWarrantyExpires, item.FieldPurchaseTime, item.FieldSoldTime:
|
|
values[i] = new(sql.NullTime)
|
|
case item.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
case item.ForeignKeys[0]: // group_items
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
case item.ForeignKeys[1]: // item_children
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
case item.ForeignKeys[2]: // location_items
|
|
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Item fields.
|
|
func (_m *Item) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case item.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
_m.ID = *value
|
|
}
|
|
case item.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
_m.CreatedAt = value.Time
|
|
}
|
|
case item.FieldUpdatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
|
} else if value.Valid {
|
|
_m.UpdatedAt = value.Time
|
|
}
|
|
case item.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
_m.Name = value.String
|
|
}
|
|
case item.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
_m.Description = value.String
|
|
}
|
|
case item.FieldImportRef:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field import_ref", values[i])
|
|
} else if value.Valid {
|
|
_m.ImportRef = value.String
|
|
}
|
|
case item.FieldNotes:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field notes", values[i])
|
|
} else if value.Valid {
|
|
_m.Notes = value.String
|
|
}
|
|
case item.FieldQuantity:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field quantity", values[i])
|
|
} else if value.Valid {
|
|
_m.Quantity = int(value.Int64)
|
|
}
|
|
case item.FieldInsured:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field insured", values[i])
|
|
} else if value.Valid {
|
|
_m.Insured = value.Bool
|
|
}
|
|
case item.FieldArchived:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field archived", values[i])
|
|
} else if value.Valid {
|
|
_m.Archived = value.Bool
|
|
}
|
|
case item.FieldAssetID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field asset_id", values[i])
|
|
} else if value.Valid {
|
|
_m.AssetID = int(value.Int64)
|
|
}
|
|
case item.FieldSyncChildItemsLocations:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sync_child_items_locations", values[i])
|
|
} else if value.Valid {
|
|
_m.SyncChildItemsLocations = value.Bool
|
|
}
|
|
case item.FieldSerialNumber:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field serial_number", values[i])
|
|
} else if value.Valid {
|
|
_m.SerialNumber = value.String
|
|
}
|
|
case item.FieldModelNumber:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field model_number", values[i])
|
|
} else if value.Valid {
|
|
_m.ModelNumber = value.String
|
|
}
|
|
case item.FieldManufacturer:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field manufacturer", values[i])
|
|
} else if value.Valid {
|
|
_m.Manufacturer = value.String
|
|
}
|
|
case item.FieldLifetimeWarranty:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field lifetime_warranty", values[i])
|
|
} else if value.Valid {
|
|
_m.LifetimeWarranty = value.Bool
|
|
}
|
|
case item.FieldWarrantyExpires:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field warranty_expires", values[i])
|
|
} else if value.Valid {
|
|
_m.WarrantyExpires = value.Time
|
|
}
|
|
case item.FieldWarrantyDetails:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field warranty_details", values[i])
|
|
} else if value.Valid {
|
|
_m.WarrantyDetails = value.String
|
|
}
|
|
case item.FieldPurchaseTime:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field purchase_time", values[i])
|
|
} else if value.Valid {
|
|
_m.PurchaseTime = value.Time
|
|
}
|
|
case item.FieldPurchaseFrom:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field purchase_from", values[i])
|
|
} else if value.Valid {
|
|
_m.PurchaseFrom = value.String
|
|
}
|
|
case item.FieldPurchasePrice:
|
|
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field purchase_price", values[i])
|
|
} else if value.Valid {
|
|
_m.PurchasePrice = value.Float64
|
|
}
|
|
case item.FieldSoldTime:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sold_time", values[i])
|
|
} else if value.Valid {
|
|
_m.SoldTime = value.Time
|
|
}
|
|
case item.FieldSoldTo:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sold_to", values[i])
|
|
} else if value.Valid {
|
|
_m.SoldTo = value.String
|
|
}
|
|
case item.FieldSoldPrice:
|
|
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sold_price", values[i])
|
|
} else if value.Valid {
|
|
_m.SoldPrice = value.Float64
|
|
}
|
|
case item.FieldSoldNotes:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field sold_notes", values[i])
|
|
} else if value.Valid {
|
|
_m.SoldNotes = value.String
|
|
}
|
|
case item.ForeignKeys[0]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field group_items", values[i])
|
|
} else if value.Valid {
|
|
_m.group_items = new(uuid.UUID)
|
|
*_m.group_items = *value.S.(*uuid.UUID)
|
|
}
|
|
case item.ForeignKeys[1]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field item_children", values[i])
|
|
} else if value.Valid {
|
|
_m.item_children = new(uuid.UUID)
|
|
*_m.item_children = *value.S.(*uuid.UUID)
|
|
}
|
|
case item.ForeignKeys[2]:
|
|
if value, ok := values[i].(*sql.NullScanner); !ok {
|
|
return fmt.Errorf("unexpected type %T for field location_items", values[i])
|
|
} else if value.Valid {
|
|
_m.location_items = new(uuid.UUID)
|
|
*_m.location_items = *value.S.(*uuid.UUID)
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Item.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *Item) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryGroup queries the "group" edge of the Item entity.
|
|
func (_m *Item) QueryGroup() *GroupQuery {
|
|
return NewItemClient(_m.config).QueryGroup(_m)
|
|
}
|
|
|
|
// QueryParent queries the "parent" edge of the Item entity.
|
|
func (_m *Item) QueryParent() *ItemQuery {
|
|
return NewItemClient(_m.config).QueryParent(_m)
|
|
}
|
|
|
|
// QueryChildren queries the "children" edge of the Item entity.
|
|
func (_m *Item) QueryChildren() *ItemQuery {
|
|
return NewItemClient(_m.config).QueryChildren(_m)
|
|
}
|
|
|
|
// QueryLabel queries the "label" edge of the Item entity.
|
|
func (_m *Item) QueryLabel() *LabelQuery {
|
|
return NewItemClient(_m.config).QueryLabel(_m)
|
|
}
|
|
|
|
// QueryLocation queries the "location" edge of the Item entity.
|
|
func (_m *Item) QueryLocation() *LocationQuery {
|
|
return NewItemClient(_m.config).QueryLocation(_m)
|
|
}
|
|
|
|
// QueryFields queries the "fields" edge of the Item entity.
|
|
func (_m *Item) QueryFields() *ItemFieldQuery {
|
|
return NewItemClient(_m.config).QueryFields(_m)
|
|
}
|
|
|
|
// QueryMaintenanceEntries queries the "maintenance_entries" edge of the Item entity.
|
|
func (_m *Item) QueryMaintenanceEntries() *MaintenanceEntryQuery {
|
|
return NewItemClient(_m.config).QueryMaintenanceEntries(_m)
|
|
}
|
|
|
|
// QueryAttachments queries the "attachments" edge of the Item entity.
|
|
func (_m *Item) QueryAttachments() *AttachmentQuery {
|
|
return NewItemClient(_m.config).QueryAttachments(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this Item.
|
|
// Note that you need to call Item.Unwrap() before calling this method if this Item
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *Item) Update() *ItemUpdateOne {
|
|
return NewItemClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the Item entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (_m *Item) Unwrap() *Item {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Item is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *Item) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Item(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("name=")
|
|
builder.WriteString(_m.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("description=")
|
|
builder.WriteString(_m.Description)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("import_ref=")
|
|
builder.WriteString(_m.ImportRef)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("notes=")
|
|
builder.WriteString(_m.Notes)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("quantity=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Quantity))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("insured=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Insured))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("archived=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Archived))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("asset_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.AssetID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sync_child_items_locations=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.SyncChildItemsLocations))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("serial_number=")
|
|
builder.WriteString(_m.SerialNumber)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("model_number=")
|
|
builder.WriteString(_m.ModelNumber)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("manufacturer=")
|
|
builder.WriteString(_m.Manufacturer)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("lifetime_warranty=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LifetimeWarranty))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("warranty_expires=")
|
|
builder.WriteString(_m.WarrantyExpires.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("warranty_details=")
|
|
builder.WriteString(_m.WarrantyDetails)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("purchase_time=")
|
|
builder.WriteString(_m.PurchaseTime.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("purchase_from=")
|
|
builder.WriteString(_m.PurchaseFrom)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("purchase_price=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.PurchasePrice))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sold_time=")
|
|
builder.WriteString(_m.SoldTime.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sold_to=")
|
|
builder.WriteString(_m.SoldTo)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sold_price=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.SoldPrice))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("sold_notes=")
|
|
builder.WriteString(_m.SoldNotes)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Items is a parsable slice of Item.
|
|
type Items []*Item
|