mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-30 17:47:24 +01:00
2663 lines
80 KiB
Go
2663 lines
80 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
|
)
|
|
|
|
// EntityUpdate is the builder for updating Entity entities.
|
|
type EntityUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *EntityMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EntityUpdate builder.
|
|
func (eu *EntityUpdate) Where(ps ...predicate.Entity) *EntityUpdate {
|
|
eu.mutation.Where(ps...)
|
|
return eu
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (eu *EntityUpdate) SetUpdatedAt(t time.Time) *EntityUpdate {
|
|
eu.mutation.SetUpdatedAt(t)
|
|
return eu
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (eu *EntityUpdate) SetName(s string) *EntityUpdate {
|
|
eu.mutation.SetName(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableName(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetName(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (eu *EntityUpdate) SetDescription(s string) *EntityUpdate {
|
|
eu.mutation.SetDescription(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableDescription(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetDescription(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (eu *EntityUpdate) ClearDescription() *EntityUpdate {
|
|
eu.mutation.ClearDescription()
|
|
return eu
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (eu *EntityUpdate) SetType(e entity.Type) *EntityUpdate {
|
|
eu.mutation.SetType(e)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableType sets the "type" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableType(e *entity.Type) *EntityUpdate {
|
|
if e != nil {
|
|
eu.SetType(*e)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (eu *EntityUpdate) SetImportRef(s string) *EntityUpdate {
|
|
eu.mutation.SetImportRef(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableImportRef(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetImportRef(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (eu *EntityUpdate) ClearImportRef() *EntityUpdate {
|
|
eu.mutation.ClearImportRef()
|
|
return eu
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (eu *EntityUpdate) SetNotes(s string) *EntityUpdate {
|
|
eu.mutation.SetNotes(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableNotes(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetNotes(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (eu *EntityUpdate) ClearNotes() *EntityUpdate {
|
|
eu.mutation.ClearNotes()
|
|
return eu
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (eu *EntityUpdate) SetQuantity(i int) *EntityUpdate {
|
|
eu.mutation.ResetQuantity()
|
|
eu.mutation.SetQuantity(i)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableQuantity(i *int) *EntityUpdate {
|
|
if i != nil {
|
|
eu.SetQuantity(*i)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddQuantity adds i to the "quantity" field.
|
|
func (eu *EntityUpdate) AddQuantity(i int) *EntityUpdate {
|
|
eu.mutation.AddQuantity(i)
|
|
return eu
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (eu *EntityUpdate) SetInsured(b bool) *EntityUpdate {
|
|
eu.mutation.SetInsured(b)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableInsured(b *bool) *EntityUpdate {
|
|
if b != nil {
|
|
eu.SetInsured(*b)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (eu *EntityUpdate) SetArchived(b bool) *EntityUpdate {
|
|
eu.mutation.SetArchived(b)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableArchived(b *bool) *EntityUpdate {
|
|
if b != nil {
|
|
eu.SetArchived(*b)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (eu *EntityUpdate) SetAssetID(i int) *EntityUpdate {
|
|
eu.mutation.ResetAssetID()
|
|
eu.mutation.SetAssetID(i)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableAssetID(i *int) *EntityUpdate {
|
|
if i != nil {
|
|
eu.SetAssetID(*i)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddAssetID adds i to the "asset_id" field.
|
|
func (eu *EntityUpdate) AddAssetID(i int) *EntityUpdate {
|
|
eu.mutation.AddAssetID(i)
|
|
return eu
|
|
}
|
|
|
|
// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field.
|
|
func (eu *EntityUpdate) SetSyncChildEntitiesLocations(b bool) *EntityUpdate {
|
|
eu.mutation.SetSyncChildEntitiesLocations(b)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSyncChildEntitiesLocations sets the "sync_child_entities_locations" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSyncChildEntitiesLocations(b *bool) *EntityUpdate {
|
|
if b != nil {
|
|
eu.SetSyncChildEntitiesLocations(*b)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (eu *EntityUpdate) SetSerialNumber(s string) *EntityUpdate {
|
|
eu.mutation.SetSerialNumber(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSerialNumber(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetSerialNumber(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (eu *EntityUpdate) ClearSerialNumber() *EntityUpdate {
|
|
eu.mutation.ClearSerialNumber()
|
|
return eu
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (eu *EntityUpdate) SetModelNumber(s string) *EntityUpdate {
|
|
eu.mutation.SetModelNumber(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableModelNumber(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetModelNumber(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (eu *EntityUpdate) ClearModelNumber() *EntityUpdate {
|
|
eu.mutation.ClearModelNumber()
|
|
return eu
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (eu *EntityUpdate) SetManufacturer(s string) *EntityUpdate {
|
|
eu.mutation.SetManufacturer(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableManufacturer(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetManufacturer(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (eu *EntityUpdate) ClearManufacturer() *EntityUpdate {
|
|
eu.mutation.ClearManufacturer()
|
|
return eu
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (eu *EntityUpdate) SetLifetimeWarranty(b bool) *EntityUpdate {
|
|
eu.mutation.SetLifetimeWarranty(b)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableLifetimeWarranty(b *bool) *EntityUpdate {
|
|
if b != nil {
|
|
eu.SetLifetimeWarranty(*b)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (eu *EntityUpdate) SetWarrantyExpires(t time.Time) *EntityUpdate {
|
|
eu.mutation.SetWarrantyExpires(t)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableWarrantyExpires(t *time.Time) *EntityUpdate {
|
|
if t != nil {
|
|
eu.SetWarrantyExpires(*t)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (eu *EntityUpdate) ClearWarrantyExpires() *EntityUpdate {
|
|
eu.mutation.ClearWarrantyExpires()
|
|
return eu
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (eu *EntityUpdate) SetWarrantyDetails(s string) *EntityUpdate {
|
|
eu.mutation.SetWarrantyDetails(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableWarrantyDetails(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetWarrantyDetails(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (eu *EntityUpdate) ClearWarrantyDetails() *EntityUpdate {
|
|
eu.mutation.ClearWarrantyDetails()
|
|
return eu
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (eu *EntityUpdate) SetPurchaseTime(t time.Time) *EntityUpdate {
|
|
eu.mutation.SetPurchaseTime(t)
|
|
return eu
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillablePurchaseTime(t *time.Time) *EntityUpdate {
|
|
if t != nil {
|
|
eu.SetPurchaseTime(*t)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (eu *EntityUpdate) ClearPurchaseTime() *EntityUpdate {
|
|
eu.mutation.ClearPurchaseTime()
|
|
return eu
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (eu *EntityUpdate) SetPurchaseFrom(s string) *EntityUpdate {
|
|
eu.mutation.SetPurchaseFrom(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillablePurchaseFrom(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetPurchaseFrom(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (eu *EntityUpdate) ClearPurchaseFrom() *EntityUpdate {
|
|
eu.mutation.ClearPurchaseFrom()
|
|
return eu
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (eu *EntityUpdate) SetPurchasePrice(f float64) *EntityUpdate {
|
|
eu.mutation.ResetPurchasePrice()
|
|
eu.mutation.SetPurchasePrice(f)
|
|
return eu
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillablePurchasePrice(f *float64) *EntityUpdate {
|
|
if f != nil {
|
|
eu.SetPurchasePrice(*f)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddPurchasePrice adds f to the "purchase_price" field.
|
|
func (eu *EntityUpdate) AddPurchasePrice(f float64) *EntityUpdate {
|
|
eu.mutation.AddPurchasePrice(f)
|
|
return eu
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (eu *EntityUpdate) SetSoldTime(t time.Time) *EntityUpdate {
|
|
eu.mutation.SetSoldTime(t)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSoldTime(t *time.Time) *EntityUpdate {
|
|
if t != nil {
|
|
eu.SetSoldTime(*t)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (eu *EntityUpdate) ClearSoldTime() *EntityUpdate {
|
|
eu.mutation.ClearSoldTime()
|
|
return eu
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (eu *EntityUpdate) SetSoldTo(s string) *EntityUpdate {
|
|
eu.mutation.SetSoldTo(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSoldTo(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetSoldTo(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (eu *EntityUpdate) ClearSoldTo() *EntityUpdate {
|
|
eu.mutation.ClearSoldTo()
|
|
return eu
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (eu *EntityUpdate) SetSoldPrice(f float64) *EntityUpdate {
|
|
eu.mutation.ResetSoldPrice()
|
|
eu.mutation.SetSoldPrice(f)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSoldPrice(f *float64) *EntityUpdate {
|
|
if f != nil {
|
|
eu.SetSoldPrice(*f)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddSoldPrice adds f to the "sold_price" field.
|
|
func (eu *EntityUpdate) AddSoldPrice(f float64) *EntityUpdate {
|
|
eu.mutation.AddSoldPrice(f)
|
|
return eu
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (eu *EntityUpdate) SetSoldNotes(s string) *EntityUpdate {
|
|
eu.mutation.SetSoldNotes(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableSoldNotes(s *string) *EntityUpdate {
|
|
if s != nil {
|
|
eu.SetSoldNotes(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (eu *EntityUpdate) ClearSoldNotes() *EntityUpdate {
|
|
eu.mutation.ClearSoldNotes()
|
|
return eu
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (eu *EntityUpdate) SetGroupID(id uuid.UUID) *EntityUpdate {
|
|
eu.mutation.SetGroupID(id)
|
|
return eu
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (eu *EntityUpdate) SetGroup(g *Group) *EntityUpdate {
|
|
return eu.SetGroupID(g.ID)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Entity entity by ID.
|
|
func (eu *EntityUpdate) SetParentID(id uuid.UUID) *EntityUpdate {
|
|
eu.mutation.SetParentID(id)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Entity entity by ID if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableParentID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
eu = eu.SetParentID(*id)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Entity entity.
|
|
func (eu *EntityUpdate) SetParent(e *Entity) *EntityUpdate {
|
|
return eu.SetParentID(e.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Entity entity by IDs.
|
|
func (eu *EntityUpdate) AddChildIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.AddChildIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Entity entity.
|
|
func (eu *EntityUpdate) AddChildren(e ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return eu.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
|
func (eu *EntityUpdate) SetEntityID(id uuid.UUID) *EntityUpdate {
|
|
eu.mutation.SetEntityID(id)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableEntityID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
eu = eu.SetEntityID(*id)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetEntity sets the "entity" edge to the Entity entity.
|
|
func (eu *EntityUpdate) SetEntity(e *Entity) *EntityUpdate {
|
|
return eu.SetEntityID(e.ID)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Entity entity by ID.
|
|
func (eu *EntityUpdate) SetLocationID(id uuid.UUID) *EntityUpdate {
|
|
eu.mutation.SetLocationID(id)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
|
|
func (eu *EntityUpdate) SetNillableLocationID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
eu = eu.SetLocationID(*id)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Entity entity.
|
|
func (eu *EntityUpdate) SetLocation(e *Entity) *EntityUpdate {
|
|
return eu.SetLocationID(e.ID)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (eu *EntityUpdate) AddLabelIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.AddLabelIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (eu *EntityUpdate) AddLabel(l ...*Label) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(l))
|
|
for i := range l {
|
|
ids[i] = l[i].ID
|
|
}
|
|
return eu.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the EntityField entity by IDs.
|
|
func (eu *EntityUpdate) AddFieldIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.AddFieldIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the EntityField entity.
|
|
func (eu *EntityUpdate) AddFields(e ...*EntityField) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return eu.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (eu *EntityUpdate) AddMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (eu *EntityUpdate) AddMaintenanceEntries(m ...*MaintenanceEntry) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return eu.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (eu *EntityUpdate) AddAttachmentIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.AddAttachmentIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (eu *EntityUpdate) AddAttachments(a ...*Attachment) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(a))
|
|
for i := range a {
|
|
ids[i] = a[i].ID
|
|
}
|
|
return eu.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the EntityMutation object of the builder.
|
|
func (eu *EntityUpdate) Mutation() *EntityMutation {
|
|
return eu.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (eu *EntityUpdate) ClearGroup() *EntityUpdate {
|
|
eu.mutation.ClearGroup()
|
|
return eu
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Entity entity.
|
|
func (eu *EntityUpdate) ClearParent() *EntityUpdate {
|
|
eu.mutation.ClearParent()
|
|
return eu
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Entity entity.
|
|
func (eu *EntityUpdate) ClearChildren() *EntityUpdate {
|
|
eu.mutation.ClearChildren()
|
|
return eu
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Entity entities by IDs.
|
|
func (eu *EntityUpdate) RemoveChildIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.RemoveChildIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Entity entities.
|
|
func (eu *EntityUpdate) RemoveChildren(e ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return eu.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearEntity clears the "entity" edge to the Entity entity.
|
|
func (eu *EntityUpdate) ClearEntity() *EntityUpdate {
|
|
eu.mutation.ClearEntity()
|
|
return eu
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Entity entity.
|
|
func (eu *EntityUpdate) ClearLocation() *EntityUpdate {
|
|
eu.mutation.ClearLocation()
|
|
return eu
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (eu *EntityUpdate) ClearLabel() *EntityUpdate {
|
|
eu.mutation.ClearLabel()
|
|
return eu
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (eu *EntityUpdate) RemoveLabelIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.RemoveLabelIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (eu *EntityUpdate) RemoveLabel(l ...*Label) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(l))
|
|
for i := range l {
|
|
ids[i] = l[i].ID
|
|
}
|
|
return eu.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the EntityField entity.
|
|
func (eu *EntityUpdate) ClearFields() *EntityUpdate {
|
|
eu.mutation.ClearFields()
|
|
return eu
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to EntityField entities by IDs.
|
|
func (eu *EntityUpdate) RemoveFieldIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.RemoveFieldIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to EntityField entities.
|
|
func (eu *EntityUpdate) RemoveFields(e ...*EntityField) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return eu.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (eu *EntityUpdate) ClearMaintenanceEntries() *EntityUpdate {
|
|
eu.mutation.ClearMaintenanceEntries()
|
|
return eu
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (eu *EntityUpdate) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (eu *EntityUpdate) RemoveMaintenanceEntries(m ...*MaintenanceEntry) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return eu.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (eu *EntityUpdate) ClearAttachments() *EntityUpdate {
|
|
eu.mutation.ClearAttachments()
|
|
return eu
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (eu *EntityUpdate) RemoveAttachmentIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
eu.mutation.RemoveAttachmentIDs(ids...)
|
|
return eu
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (eu *EntityUpdate) RemoveAttachments(a ...*Attachment) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(a))
|
|
for i := range a {
|
|
ids[i] = a[i].ID
|
|
}
|
|
return eu.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (eu *EntityUpdate) Save(ctx context.Context) (int, error) {
|
|
eu.defaults()
|
|
return withHooks(ctx, eu.sqlSave, eu.mutation, eu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (eu *EntityUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := eu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (eu *EntityUpdate) Exec(ctx context.Context) error {
|
|
_, err := eu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (eu *EntityUpdate) ExecX(ctx context.Context) {
|
|
if err := eu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (eu *EntityUpdate) defaults() {
|
|
if _, ok := eu.mutation.UpdatedAt(); !ok {
|
|
v := entity.UpdateDefaultUpdatedAt()
|
|
eu.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (eu *EntityUpdate) check() error {
|
|
if v, ok := eu.mutation.Name(); ok {
|
|
if err := entity.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Entity.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.Description(); ok {
|
|
if err := entity.DescriptionValidator(v); err != nil {
|
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Entity.description": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.GetType(); ok {
|
|
if err := entity.TypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Entity.type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.ImportRef(); ok {
|
|
if err := entity.ImportRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Entity.import_ref": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.Notes(); ok {
|
|
if err := entity.NotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Entity.notes": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.SerialNumber(); ok {
|
|
if err := entity.SerialNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Entity.serial_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.ModelNumber(); ok {
|
|
if err := entity.ModelNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Entity.model_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.Manufacturer(); ok {
|
|
if err := entity.ManufacturerValidator(v); err != nil {
|
|
return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Entity.manufacturer": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.WarrantyDetails(); ok {
|
|
if err := entity.WarrantyDetailsValidator(v); err != nil {
|
|
return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Entity.warranty_details": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := eu.mutation.SoldNotes(); ok {
|
|
if err := entity.SoldNotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Entity.sold_notes": %w`, err)}
|
|
}
|
|
}
|
|
if eu.mutation.GroupCleared() && len(eu.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Entity.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (eu *EntityUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
if err := eu.check(); err != nil {
|
|
return n, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(entity.Table, entity.Columns, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
|
|
if ps := eu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := eu.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := eu.mutation.Name(); ok {
|
|
_spec.SetField(entity.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := eu.mutation.Description(); ok {
|
|
_spec.SetField(entity.FieldDescription, field.TypeString, value)
|
|
}
|
|
if eu.mutation.DescriptionCleared() {
|
|
_spec.ClearField(entity.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.GetType(); ok {
|
|
_spec.SetField(entity.FieldType, field.TypeEnum, value)
|
|
}
|
|
if value, ok := eu.mutation.ImportRef(); ok {
|
|
_spec.SetField(entity.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if eu.mutation.ImportRefCleared() {
|
|
_spec.ClearField(entity.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.Notes(); ok {
|
|
_spec.SetField(entity.FieldNotes, field.TypeString, value)
|
|
}
|
|
if eu.mutation.NotesCleared() {
|
|
_spec.ClearField(entity.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.Quantity(); ok {
|
|
_spec.SetField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.Insured(); ok {
|
|
_spec.SetField(entity.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := eu.mutation.Archived(); ok {
|
|
_spec.SetField(entity.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := eu.mutation.AssetID(); ok {
|
|
_spec.SetField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.SyncChildEntitiesLocations(); ok {
|
|
_spec.SetField(entity.FieldSyncChildEntitiesLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := eu.mutation.SerialNumber(); ok {
|
|
_spec.SetField(entity.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if eu.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(entity.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.ModelNumber(); ok {
|
|
_spec.SetField(entity.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if eu.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(entity.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.Manufacturer(); ok {
|
|
_spec.SetField(entity.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if eu.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(entity.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(entity.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := eu.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(entity.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if eu.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := eu.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(entity.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if eu.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(entity.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if eu.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := eu.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(entity.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if eu.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := eu.mutation.SoldTime(); ok {
|
|
_spec.SetField(entity.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if eu.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(entity.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := eu.mutation.SoldTo(); ok {
|
|
_spec.SetField(entity.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if eu.mutation.SoldToCleared() {
|
|
_spec.ClearField(entity.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := eu.mutation.SoldPrice(); ok {
|
|
_spec.SetField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := eu.mutation.SoldNotes(); ok {
|
|
_spec.SetField(entity.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if eu.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(entity.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if eu.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.GroupTable,
|
|
Columns: []string{entity.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.GroupTable,
|
|
Columns: []string{entity.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.ParentTable,
|
|
Columns: []string{entity.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.ParentTable,
|
|
Columns: []string{entity.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !eu.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: true,
|
|
Table: entity.EntityTable,
|
|
Columns: []string{entity.EntityColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.EntityIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: true,
|
|
Table: entity.EntityTable,
|
|
Columns: []string{entity.EntityColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: entity.LocationTable,
|
|
Columns: []string{entity.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: entity.LocationTable,
|
|
Columns: []string{entity.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.RemovedLabelIDs(); len(nodes) > 0 && !eu.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.LabelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !eu.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.FieldsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !eu.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if eu.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !eu.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.AttachmentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{entity.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
eu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// EntityUpdateOne is the builder for updating a single Entity entity.
|
|
type EntityUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *EntityMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (euo *EntityUpdateOne) SetUpdatedAt(t time.Time) *EntityUpdateOne {
|
|
euo.mutation.SetUpdatedAt(t)
|
|
return euo
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (euo *EntityUpdateOne) SetName(s string) *EntityUpdateOne {
|
|
euo.mutation.SetName(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableName(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetName(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (euo *EntityUpdateOne) SetDescription(s string) *EntityUpdateOne {
|
|
euo.mutation.SetDescription(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableDescription(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetDescription(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (euo *EntityUpdateOne) ClearDescription() *EntityUpdateOne {
|
|
euo.mutation.ClearDescription()
|
|
return euo
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (euo *EntityUpdateOne) SetType(e entity.Type) *EntityUpdateOne {
|
|
euo.mutation.SetType(e)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableType sets the "type" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableType(e *entity.Type) *EntityUpdateOne {
|
|
if e != nil {
|
|
euo.SetType(*e)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (euo *EntityUpdateOne) SetImportRef(s string) *EntityUpdateOne {
|
|
euo.mutation.SetImportRef(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableImportRef(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetImportRef(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (euo *EntityUpdateOne) ClearImportRef() *EntityUpdateOne {
|
|
euo.mutation.ClearImportRef()
|
|
return euo
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (euo *EntityUpdateOne) SetNotes(s string) *EntityUpdateOne {
|
|
euo.mutation.SetNotes(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableNotes(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetNotes(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (euo *EntityUpdateOne) ClearNotes() *EntityUpdateOne {
|
|
euo.mutation.ClearNotes()
|
|
return euo
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (euo *EntityUpdateOne) SetQuantity(i int) *EntityUpdateOne {
|
|
euo.mutation.ResetQuantity()
|
|
euo.mutation.SetQuantity(i)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableQuantity(i *int) *EntityUpdateOne {
|
|
if i != nil {
|
|
euo.SetQuantity(*i)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddQuantity adds i to the "quantity" field.
|
|
func (euo *EntityUpdateOne) AddQuantity(i int) *EntityUpdateOne {
|
|
euo.mutation.AddQuantity(i)
|
|
return euo
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (euo *EntityUpdateOne) SetInsured(b bool) *EntityUpdateOne {
|
|
euo.mutation.SetInsured(b)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableInsured(b *bool) *EntityUpdateOne {
|
|
if b != nil {
|
|
euo.SetInsured(*b)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (euo *EntityUpdateOne) SetArchived(b bool) *EntityUpdateOne {
|
|
euo.mutation.SetArchived(b)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableArchived(b *bool) *EntityUpdateOne {
|
|
if b != nil {
|
|
euo.SetArchived(*b)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (euo *EntityUpdateOne) SetAssetID(i int) *EntityUpdateOne {
|
|
euo.mutation.ResetAssetID()
|
|
euo.mutation.SetAssetID(i)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableAssetID(i *int) *EntityUpdateOne {
|
|
if i != nil {
|
|
euo.SetAssetID(*i)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddAssetID adds i to the "asset_id" field.
|
|
func (euo *EntityUpdateOne) AddAssetID(i int) *EntityUpdateOne {
|
|
euo.mutation.AddAssetID(i)
|
|
return euo
|
|
}
|
|
|
|
// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field.
|
|
func (euo *EntityUpdateOne) SetSyncChildEntitiesLocations(b bool) *EntityUpdateOne {
|
|
euo.mutation.SetSyncChildEntitiesLocations(b)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSyncChildEntitiesLocations sets the "sync_child_entities_locations" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSyncChildEntitiesLocations(b *bool) *EntityUpdateOne {
|
|
if b != nil {
|
|
euo.SetSyncChildEntitiesLocations(*b)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (euo *EntityUpdateOne) SetSerialNumber(s string) *EntityUpdateOne {
|
|
euo.mutation.SetSerialNumber(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSerialNumber(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetSerialNumber(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (euo *EntityUpdateOne) ClearSerialNumber() *EntityUpdateOne {
|
|
euo.mutation.ClearSerialNumber()
|
|
return euo
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (euo *EntityUpdateOne) SetModelNumber(s string) *EntityUpdateOne {
|
|
euo.mutation.SetModelNumber(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableModelNumber(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetModelNumber(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (euo *EntityUpdateOne) ClearModelNumber() *EntityUpdateOne {
|
|
euo.mutation.ClearModelNumber()
|
|
return euo
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (euo *EntityUpdateOne) SetManufacturer(s string) *EntityUpdateOne {
|
|
euo.mutation.SetManufacturer(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableManufacturer(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetManufacturer(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (euo *EntityUpdateOne) ClearManufacturer() *EntityUpdateOne {
|
|
euo.mutation.ClearManufacturer()
|
|
return euo
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (euo *EntityUpdateOne) SetLifetimeWarranty(b bool) *EntityUpdateOne {
|
|
euo.mutation.SetLifetimeWarranty(b)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableLifetimeWarranty(b *bool) *EntityUpdateOne {
|
|
if b != nil {
|
|
euo.SetLifetimeWarranty(*b)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (euo *EntityUpdateOne) SetWarrantyExpires(t time.Time) *EntityUpdateOne {
|
|
euo.mutation.SetWarrantyExpires(t)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableWarrantyExpires(t *time.Time) *EntityUpdateOne {
|
|
if t != nil {
|
|
euo.SetWarrantyExpires(*t)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (euo *EntityUpdateOne) ClearWarrantyExpires() *EntityUpdateOne {
|
|
euo.mutation.ClearWarrantyExpires()
|
|
return euo
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (euo *EntityUpdateOne) SetWarrantyDetails(s string) *EntityUpdateOne {
|
|
euo.mutation.SetWarrantyDetails(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableWarrantyDetails(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetWarrantyDetails(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (euo *EntityUpdateOne) ClearWarrantyDetails() *EntityUpdateOne {
|
|
euo.mutation.ClearWarrantyDetails()
|
|
return euo
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (euo *EntityUpdateOne) SetPurchaseTime(t time.Time) *EntityUpdateOne {
|
|
euo.mutation.SetPurchaseTime(t)
|
|
return euo
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillablePurchaseTime(t *time.Time) *EntityUpdateOne {
|
|
if t != nil {
|
|
euo.SetPurchaseTime(*t)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (euo *EntityUpdateOne) ClearPurchaseTime() *EntityUpdateOne {
|
|
euo.mutation.ClearPurchaseTime()
|
|
return euo
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (euo *EntityUpdateOne) SetPurchaseFrom(s string) *EntityUpdateOne {
|
|
euo.mutation.SetPurchaseFrom(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillablePurchaseFrom(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetPurchaseFrom(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (euo *EntityUpdateOne) ClearPurchaseFrom() *EntityUpdateOne {
|
|
euo.mutation.ClearPurchaseFrom()
|
|
return euo
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (euo *EntityUpdateOne) SetPurchasePrice(f float64) *EntityUpdateOne {
|
|
euo.mutation.ResetPurchasePrice()
|
|
euo.mutation.SetPurchasePrice(f)
|
|
return euo
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillablePurchasePrice(f *float64) *EntityUpdateOne {
|
|
if f != nil {
|
|
euo.SetPurchasePrice(*f)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddPurchasePrice adds f to the "purchase_price" field.
|
|
func (euo *EntityUpdateOne) AddPurchasePrice(f float64) *EntityUpdateOne {
|
|
euo.mutation.AddPurchasePrice(f)
|
|
return euo
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (euo *EntityUpdateOne) SetSoldTime(t time.Time) *EntityUpdateOne {
|
|
euo.mutation.SetSoldTime(t)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSoldTime(t *time.Time) *EntityUpdateOne {
|
|
if t != nil {
|
|
euo.SetSoldTime(*t)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (euo *EntityUpdateOne) ClearSoldTime() *EntityUpdateOne {
|
|
euo.mutation.ClearSoldTime()
|
|
return euo
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (euo *EntityUpdateOne) SetSoldTo(s string) *EntityUpdateOne {
|
|
euo.mutation.SetSoldTo(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSoldTo(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetSoldTo(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (euo *EntityUpdateOne) ClearSoldTo() *EntityUpdateOne {
|
|
euo.mutation.ClearSoldTo()
|
|
return euo
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (euo *EntityUpdateOne) SetSoldPrice(f float64) *EntityUpdateOne {
|
|
euo.mutation.ResetSoldPrice()
|
|
euo.mutation.SetSoldPrice(f)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSoldPrice(f *float64) *EntityUpdateOne {
|
|
if f != nil {
|
|
euo.SetSoldPrice(*f)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddSoldPrice adds f to the "sold_price" field.
|
|
func (euo *EntityUpdateOne) AddSoldPrice(f float64) *EntityUpdateOne {
|
|
euo.mutation.AddSoldPrice(f)
|
|
return euo
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (euo *EntityUpdateOne) SetSoldNotes(s string) *EntityUpdateOne {
|
|
euo.mutation.SetSoldNotes(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableSoldNotes(s *string) *EntityUpdateOne {
|
|
if s != nil {
|
|
euo.SetSoldNotes(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (euo *EntityUpdateOne) ClearSoldNotes() *EntityUpdateOne {
|
|
euo.mutation.ClearSoldNotes()
|
|
return euo
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (euo *EntityUpdateOne) SetGroupID(id uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.SetGroupID(id)
|
|
return euo
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (euo *EntityUpdateOne) SetGroup(g *Group) *EntityUpdateOne {
|
|
return euo.SetGroupID(g.ID)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Entity entity by ID.
|
|
func (euo *EntityUpdateOne) SetParentID(id uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.SetParentID(id)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Entity entity by ID if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableParentID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
euo = euo.SetParentID(*id)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) SetParent(e *Entity) *EntityUpdateOne {
|
|
return euo.SetParentID(e.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Entity entity by IDs.
|
|
func (euo *EntityUpdateOne) AddChildIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.AddChildIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Entity entity.
|
|
func (euo *EntityUpdateOne) AddChildren(e ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return euo.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetEntityID sets the "entity" edge to the Entity entity by ID.
|
|
func (euo *EntityUpdateOne) SetEntityID(id uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.SetEntityID(id)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableEntityID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
euo = euo.SetEntityID(*id)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetEntity sets the "entity" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) SetEntity(e *Entity) *EntityUpdateOne {
|
|
return euo.SetEntityID(e.ID)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Entity entity by ID.
|
|
func (euo *EntityUpdateOne) SetLocationID(id uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.SetLocationID(id)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
|
|
func (euo *EntityUpdateOne) SetNillableLocationID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
euo = euo.SetLocationID(*id)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) SetLocation(e *Entity) *EntityUpdateOne {
|
|
return euo.SetLocationID(e.ID)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (euo *EntityUpdateOne) AddLabelIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.AddLabelIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (euo *EntityUpdateOne) AddLabel(l ...*Label) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(l))
|
|
for i := range l {
|
|
ids[i] = l[i].ID
|
|
}
|
|
return euo.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the EntityField entity by IDs.
|
|
func (euo *EntityUpdateOne) AddFieldIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.AddFieldIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the EntityField entity.
|
|
func (euo *EntityUpdateOne) AddFields(e ...*EntityField) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return euo.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (euo *EntityUpdateOne) AddMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (euo *EntityUpdateOne) AddMaintenanceEntries(m ...*MaintenanceEntry) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return euo.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (euo *EntityUpdateOne) AddAttachmentIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.AddAttachmentIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (euo *EntityUpdateOne) AddAttachments(a ...*Attachment) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(a))
|
|
for i := range a {
|
|
ids[i] = a[i].ID
|
|
}
|
|
return euo.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the EntityMutation object of the builder.
|
|
func (euo *EntityUpdateOne) Mutation() *EntityMutation {
|
|
return euo.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (euo *EntityUpdateOne) ClearGroup() *EntityUpdateOne {
|
|
euo.mutation.ClearGroup()
|
|
return euo
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) ClearParent() *EntityUpdateOne {
|
|
euo.mutation.ClearParent()
|
|
return euo
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Entity entity.
|
|
func (euo *EntityUpdateOne) ClearChildren() *EntityUpdateOne {
|
|
euo.mutation.ClearChildren()
|
|
return euo
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Entity entities by IDs.
|
|
func (euo *EntityUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.RemoveChildIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Entity entities.
|
|
func (euo *EntityUpdateOne) RemoveChildren(e ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return euo.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearEntity clears the "entity" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) ClearEntity() *EntityUpdateOne {
|
|
euo.mutation.ClearEntity()
|
|
return euo
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Entity entity.
|
|
func (euo *EntityUpdateOne) ClearLocation() *EntityUpdateOne {
|
|
euo.mutation.ClearLocation()
|
|
return euo
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (euo *EntityUpdateOne) ClearLabel() *EntityUpdateOne {
|
|
euo.mutation.ClearLabel()
|
|
return euo
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (euo *EntityUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.RemoveLabelIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (euo *EntityUpdateOne) RemoveLabel(l ...*Label) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(l))
|
|
for i := range l {
|
|
ids[i] = l[i].ID
|
|
}
|
|
return euo.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the EntityField entity.
|
|
func (euo *EntityUpdateOne) ClearFields() *EntityUpdateOne {
|
|
euo.mutation.ClearFields()
|
|
return euo
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to EntityField entities by IDs.
|
|
func (euo *EntityUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.RemoveFieldIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to EntityField entities.
|
|
func (euo *EntityUpdateOne) RemoveFields(e ...*EntityField) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(e))
|
|
for i := range e {
|
|
ids[i] = e[i].ID
|
|
}
|
|
return euo.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (euo *EntityUpdateOne) ClearMaintenanceEntries() *EntityUpdateOne {
|
|
euo.mutation.ClearMaintenanceEntries()
|
|
return euo
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (euo *EntityUpdateOne) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (euo *EntityUpdateOne) RemoveMaintenanceEntries(m ...*MaintenanceEntry) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(m))
|
|
for i := range m {
|
|
ids[i] = m[i].ID
|
|
}
|
|
return euo.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (euo *EntityUpdateOne) ClearAttachments() *EntityUpdateOne {
|
|
euo.mutation.ClearAttachments()
|
|
return euo
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (euo *EntityUpdateOne) RemoveAttachmentIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
euo.mutation.RemoveAttachmentIDs(ids...)
|
|
return euo
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (euo *EntityUpdateOne) RemoveAttachments(a ...*Attachment) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(a))
|
|
for i := range a {
|
|
ids[i] = a[i].ID
|
|
}
|
|
return euo.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the EntityUpdate builder.
|
|
func (euo *EntityUpdateOne) Where(ps ...predicate.Entity) *EntityUpdateOne {
|
|
euo.mutation.Where(ps...)
|
|
return euo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (euo *EntityUpdateOne) Select(field string, fields ...string) *EntityUpdateOne {
|
|
euo.fields = append([]string{field}, fields...)
|
|
return euo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Entity entity.
|
|
func (euo *EntityUpdateOne) Save(ctx context.Context) (*Entity, error) {
|
|
euo.defaults()
|
|
return withHooks(ctx, euo.sqlSave, euo.mutation, euo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (euo *EntityUpdateOne) SaveX(ctx context.Context) *Entity {
|
|
node, err := euo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (euo *EntityUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := euo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (euo *EntityUpdateOne) ExecX(ctx context.Context) {
|
|
if err := euo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (euo *EntityUpdateOne) defaults() {
|
|
if _, ok := euo.mutation.UpdatedAt(); !ok {
|
|
v := entity.UpdateDefaultUpdatedAt()
|
|
euo.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (euo *EntityUpdateOne) check() error {
|
|
if v, ok := euo.mutation.Name(); ok {
|
|
if err := entity.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Entity.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.Description(); ok {
|
|
if err := entity.DescriptionValidator(v); err != nil {
|
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Entity.description": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.GetType(); ok {
|
|
if err := entity.TypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Entity.type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.ImportRef(); ok {
|
|
if err := entity.ImportRefValidator(v); err != nil {
|
|
return &ValidationError{Name: "import_ref", err: fmt.Errorf(`ent: validator failed for field "Entity.import_ref": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.Notes(); ok {
|
|
if err := entity.NotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "notes", err: fmt.Errorf(`ent: validator failed for field "Entity.notes": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.SerialNumber(); ok {
|
|
if err := entity.SerialNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "serial_number", err: fmt.Errorf(`ent: validator failed for field "Entity.serial_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.ModelNumber(); ok {
|
|
if err := entity.ModelNumberValidator(v); err != nil {
|
|
return &ValidationError{Name: "model_number", err: fmt.Errorf(`ent: validator failed for field "Entity.model_number": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.Manufacturer(); ok {
|
|
if err := entity.ManufacturerValidator(v); err != nil {
|
|
return &ValidationError{Name: "manufacturer", err: fmt.Errorf(`ent: validator failed for field "Entity.manufacturer": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.WarrantyDetails(); ok {
|
|
if err := entity.WarrantyDetailsValidator(v); err != nil {
|
|
return &ValidationError{Name: "warranty_details", err: fmt.Errorf(`ent: validator failed for field "Entity.warranty_details": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := euo.mutation.SoldNotes(); ok {
|
|
if err := entity.SoldNotesValidator(v); err != nil {
|
|
return &ValidationError{Name: "sold_notes", err: fmt.Errorf(`ent: validator failed for field "Entity.sold_notes": %w`, err)}
|
|
}
|
|
}
|
|
if euo.mutation.GroupCleared() && len(euo.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Entity.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (euo *EntityUpdateOne) sqlSave(ctx context.Context) (_node *Entity, err error) {
|
|
if err := euo.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(entity.Table, entity.Columns, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
|
|
id, ok := euo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Entity.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := euo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, entity.FieldID)
|
|
for _, f := range fields {
|
|
if !entity.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != entity.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := euo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := euo.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := euo.mutation.Name(); ok {
|
|
_spec.SetField(entity.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := euo.mutation.Description(); ok {
|
|
_spec.SetField(entity.FieldDescription, field.TypeString, value)
|
|
}
|
|
if euo.mutation.DescriptionCleared() {
|
|
_spec.ClearField(entity.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.GetType(); ok {
|
|
_spec.SetField(entity.FieldType, field.TypeEnum, value)
|
|
}
|
|
if value, ok := euo.mutation.ImportRef(); ok {
|
|
_spec.SetField(entity.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if euo.mutation.ImportRefCleared() {
|
|
_spec.ClearField(entity.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.Notes(); ok {
|
|
_spec.SetField(entity.FieldNotes, field.TypeString, value)
|
|
}
|
|
if euo.mutation.NotesCleared() {
|
|
_spec.ClearField(entity.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.Quantity(); ok {
|
|
_spec.SetField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.Insured(); ok {
|
|
_spec.SetField(entity.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := euo.mutation.Archived(); ok {
|
|
_spec.SetField(entity.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := euo.mutation.AssetID(); ok {
|
|
_spec.SetField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.SyncChildEntitiesLocations(); ok {
|
|
_spec.SetField(entity.FieldSyncChildEntitiesLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := euo.mutation.SerialNumber(); ok {
|
|
_spec.SetField(entity.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if euo.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(entity.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.ModelNumber(); ok {
|
|
_spec.SetField(entity.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if euo.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(entity.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.Manufacturer(); ok {
|
|
_spec.SetField(entity.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if euo.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(entity.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(entity.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := euo.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(entity.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if euo.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := euo.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(entity.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if euo.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(entity.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if euo.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := euo.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(entity.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if euo.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := euo.mutation.SoldTime(); ok {
|
|
_spec.SetField(entity.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if euo.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(entity.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := euo.mutation.SoldTo(); ok {
|
|
_spec.SetField(entity.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if euo.mutation.SoldToCleared() {
|
|
_spec.ClearField(entity.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := euo.mutation.SoldPrice(); ok {
|
|
_spec.SetField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := euo.mutation.SoldNotes(); ok {
|
|
_spec.SetField(entity.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if euo.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(entity.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if euo.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.GroupTable,
|
|
Columns: []string{entity.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.GroupTable,
|
|
Columns: []string{entity.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.ParentTable,
|
|
Columns: []string{entity.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.ParentTable,
|
|
Columns: []string{entity.ParentColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !euo.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.ChildrenTable,
|
|
Columns: []string{entity.ChildrenColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: true,
|
|
Table: entity.EntityTable,
|
|
Columns: []string{entity.EntityColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.EntityIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: true,
|
|
Table: entity.EntityTable,
|
|
Columns: []string{entity.EntityColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: entity.LocationTable,
|
|
Columns: []string{entity.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: entity.LocationTable,
|
|
Columns: []string{entity.LocationColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.RemovedLabelIDs(); len(nodes) > 0 && !euo.mutation.LabelCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.LabelIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: entity.LabelTable,
|
|
Columns: entity.LabelPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !euo.mutation.FieldsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.FieldsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.FieldsTable,
|
|
Columns: []string{entity.FieldsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entityfield.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !euo.mutation.MaintenanceEntriesCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.MaintenanceEntriesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.MaintenanceEntriesTable,
|
|
Columns: []string{entity.MaintenanceEntriesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if euo.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !euo.mutation.AttachmentsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.AttachmentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: entity.AttachmentsTable,
|
|
Columns: []string{entity.AttachmentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(attachment.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Entity{config: euo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, euo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{entity.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
euo.mutation.done = true
|
|
return _node, nil
|
|
}
|