mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-25 23:03:41 +01:00
2782 lines
83 KiB
Go
Generated
2782 lines
83 KiB
Go
Generated
// 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/entitytype"
|
|
"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 (_u *EntityUpdate) Where(ps ...predicate.Entity) *EntityUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *EntityUpdate) SetUpdatedAt(v time.Time) *EntityUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *EntityUpdate) SetName(v string) *EntityUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableName(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *EntityUpdate) SetDescription(v string) *EntityUpdate {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableDescription(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *EntityUpdate) ClearDescription() *EntityUpdate {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (_u *EntityUpdate) SetImportRef(v string) *EntityUpdate {
|
|
_u.mutation.SetImportRef(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableImportRef(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetImportRef(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (_u *EntityUpdate) ClearImportRef() *EntityUpdate {
|
|
_u.mutation.ClearImportRef()
|
|
return _u
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (_u *EntityUpdate) SetNotes(v string) *EntityUpdate {
|
|
_u.mutation.SetNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableNotes(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (_u *EntityUpdate) ClearNotes() *EntityUpdate {
|
|
_u.mutation.ClearNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *EntityUpdate) SetQuantity(v int) *EntityUpdate {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableQuantity(v *int) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *EntityUpdate) AddQuantity(v int) *EntityUpdate {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (_u *EntityUpdate) SetInsured(v bool) *EntityUpdate {
|
|
_u.mutation.SetInsured(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableInsured(v *bool) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetInsured(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (_u *EntityUpdate) SetArchived(v bool) *EntityUpdate {
|
|
_u.mutation.SetArchived(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableArchived(v *bool) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetArchived(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (_u *EntityUpdate) SetAssetID(v int) *EntityUpdate {
|
|
_u.mutation.ResetAssetID()
|
|
_u.mutation.SetAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableAssetID(v *int) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetAssetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAssetID adds value to the "asset_id" field.
|
|
func (_u *EntityUpdate) AddAssetID(v int) *EntityUpdate {
|
|
_u.mutation.AddAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field.
|
|
func (_u *EntityUpdate) SetSyncChildEntitiesLocations(v bool) *EntityUpdate {
|
|
_u.mutation.SetSyncChildEntitiesLocations(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSyncChildEntitiesLocations sets the "sync_child_entities_locations" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSyncChildEntitiesLocations(v *bool) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSyncChildEntitiesLocations(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (_u *EntityUpdate) SetSerialNumber(v string) *EntityUpdate {
|
|
_u.mutation.SetSerialNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSerialNumber(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSerialNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (_u *EntityUpdate) ClearSerialNumber() *EntityUpdate {
|
|
_u.mutation.ClearSerialNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (_u *EntityUpdate) SetModelNumber(v string) *EntityUpdate {
|
|
_u.mutation.SetModelNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableModelNumber(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetModelNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (_u *EntityUpdate) ClearModelNumber() *EntityUpdate {
|
|
_u.mutation.ClearModelNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (_u *EntityUpdate) SetManufacturer(v string) *EntityUpdate {
|
|
_u.mutation.SetManufacturer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableManufacturer(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetManufacturer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (_u *EntityUpdate) ClearManufacturer() *EntityUpdate {
|
|
_u.mutation.ClearManufacturer()
|
|
return _u
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (_u *EntityUpdate) SetLifetimeWarranty(v bool) *EntityUpdate {
|
|
_u.mutation.SetLifetimeWarranty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableLifetimeWarranty(v *bool) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetLifetimeWarranty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (_u *EntityUpdate) SetWarrantyExpires(v time.Time) *EntityUpdate {
|
|
_u.mutation.SetWarrantyExpires(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableWarrantyExpires(v *time.Time) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetWarrantyExpires(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (_u *EntityUpdate) ClearWarrantyExpires() *EntityUpdate {
|
|
_u.mutation.ClearWarrantyExpires()
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (_u *EntityUpdate) SetWarrantyDetails(v string) *EntityUpdate {
|
|
_u.mutation.SetWarrantyDetails(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableWarrantyDetails(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetWarrantyDetails(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (_u *EntityUpdate) ClearWarrantyDetails() *EntityUpdate {
|
|
_u.mutation.ClearWarrantyDetails()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (_u *EntityUpdate) SetPurchaseTime(v time.Time) *EntityUpdate {
|
|
_u.mutation.SetPurchaseTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillablePurchaseTime(v *time.Time) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetPurchaseTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (_u *EntityUpdate) ClearPurchaseTime() *EntityUpdate {
|
|
_u.mutation.ClearPurchaseTime()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (_u *EntityUpdate) SetPurchaseFrom(v string) *EntityUpdate {
|
|
_u.mutation.SetPurchaseFrom(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillablePurchaseFrom(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetPurchaseFrom(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (_u *EntityUpdate) ClearPurchaseFrom() *EntityUpdate {
|
|
_u.mutation.ClearPurchaseFrom()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (_u *EntityUpdate) SetPurchasePrice(v float64) *EntityUpdate {
|
|
_u.mutation.ResetPurchasePrice()
|
|
_u.mutation.SetPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillablePurchasePrice(v *float64) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetPurchasePrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPurchasePrice adds value to the "purchase_price" field.
|
|
func (_u *EntityUpdate) AddPurchasePrice(v float64) *EntityUpdate {
|
|
_u.mutation.AddPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (_u *EntityUpdate) SetSoldTime(v time.Time) *EntityUpdate {
|
|
_u.mutation.SetSoldTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSoldTime(v *time.Time) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSoldTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (_u *EntityUpdate) ClearSoldTime() *EntityUpdate {
|
|
_u.mutation.ClearSoldTime()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (_u *EntityUpdate) SetSoldTo(v string) *EntityUpdate {
|
|
_u.mutation.SetSoldTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSoldTo(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSoldTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (_u *EntityUpdate) ClearSoldTo() *EntityUpdate {
|
|
_u.mutation.ClearSoldTo()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (_u *EntityUpdate) SetSoldPrice(v float64) *EntityUpdate {
|
|
_u.mutation.ResetSoldPrice()
|
|
_u.mutation.SetSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSoldPrice(v *float64) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSoldPrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSoldPrice adds value to the "sold_price" field.
|
|
func (_u *EntityUpdate) AddSoldPrice(v float64) *EntityUpdate {
|
|
_u.mutation.AddSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (_u *EntityUpdate) SetSoldNotes(v string) *EntityUpdate {
|
|
_u.mutation.SetSoldNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableSoldNotes(v *string) *EntityUpdate {
|
|
if v != nil {
|
|
_u.SetSoldNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (_u *EntityUpdate) ClearSoldNotes() *EntityUpdate {
|
|
_u.mutation.ClearSoldNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *EntityUpdate) SetGroupID(id uuid.UUID) *EntityUpdate {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *EntityUpdate) SetGroup(v *Group) *EntityUpdate {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Entity entity by IDs.
|
|
func (_u *EntityUpdate) AddChildIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Entity entity.
|
|
func (_u *EntityUpdate) AddChildren(v ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Entity entity by ID.
|
|
func (_u *EntityUpdate) SetParentID(id uuid.UUID) *EntityUpdate {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Entity entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableParentID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Entity entity.
|
|
func (_u *EntityUpdate) SetParent(v *Entity) *EntityUpdate {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// AddEntityIDs adds the "entity" edge to the Entity entity by IDs.
|
|
func (_u *EntityUpdate) AddEntityIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddEntityIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddEntity adds the "entity" edges to the Entity entity.
|
|
func (_u *EntityUpdate) AddEntity(v ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddEntityIDs(ids...)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Entity entity by ID.
|
|
func (_u *EntityUpdate) SetLocationID(id uuid.UUID) *EntityUpdate {
|
|
_u.mutation.SetLocationID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableLocationID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
_u = _u.SetLocationID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Entity entity.
|
|
func (_u *EntityUpdate) SetLocation(v *Entity) *EntityUpdate {
|
|
return _u.SetLocationID(v.ID)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (_u *EntityUpdate) AddLabelIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (_u *EntityUpdate) AddLabel(v ...*Label) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// SetTypeID sets the "type" edge to the EntityType entity by ID.
|
|
func (_u *EntityUpdate) SetTypeID(id uuid.UUID) *EntityUpdate {
|
|
_u.mutation.SetTypeID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTypeID sets the "type" edge to the EntityType entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdate) SetNillableTypeID(id *uuid.UUID) *EntityUpdate {
|
|
if id != nil {
|
|
_u = _u.SetTypeID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetType sets the "type" edge to the EntityType entity.
|
|
func (_u *EntityUpdate) SetType(v *EntityType) *EntityUpdate {
|
|
return _u.SetTypeID(v.ID)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the EntityField entity by IDs.
|
|
func (_u *EntityUpdate) AddFieldIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the EntityField entity.
|
|
func (_u *EntityUpdate) AddFields(v ...*EntityField) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (_u *EntityUpdate) AddMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *EntityUpdate) AddMaintenanceEntries(v ...*MaintenanceEntry) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (_u *EntityUpdate) AddAttachmentIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.AddAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (_u *EntityUpdate) AddAttachments(v ...*Attachment) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the EntityMutation object of the builder.
|
|
func (_u *EntityUpdate) Mutation() *EntityMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *EntityUpdate) ClearGroup() *EntityUpdate {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Entity entity.
|
|
func (_u *EntityUpdate) ClearChildren() *EntityUpdate {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Entity entities by IDs.
|
|
func (_u *EntityUpdate) RemoveChildIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Entity entities.
|
|
func (_u *EntityUpdate) RemoveChildren(v ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Entity entity.
|
|
func (_u *EntityUpdate) ClearParent() *EntityUpdate {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// ClearEntity clears all "entity" edges to the Entity entity.
|
|
func (_u *EntityUpdate) ClearEntity() *EntityUpdate {
|
|
_u.mutation.ClearEntity()
|
|
return _u
|
|
}
|
|
|
|
// RemoveEntityIDs removes the "entity" edge to Entity entities by IDs.
|
|
func (_u *EntityUpdate) RemoveEntityIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveEntityIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveEntity removes "entity" edges to Entity entities.
|
|
func (_u *EntityUpdate) RemoveEntity(v ...*Entity) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveEntityIDs(ids...)
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Entity entity.
|
|
func (_u *EntityUpdate) ClearLocation() *EntityUpdate {
|
|
_u.mutation.ClearLocation()
|
|
return _u
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (_u *EntityUpdate) ClearLabel() *EntityUpdate {
|
|
_u.mutation.ClearLabel()
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (_u *EntityUpdate) RemoveLabelIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (_u *EntityUpdate) RemoveLabel(v ...*Label) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearType clears the "type" edge to the EntityType entity.
|
|
func (_u *EntityUpdate) ClearType() *EntityUpdate {
|
|
_u.mutation.ClearType()
|
|
return _u
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the EntityField entity.
|
|
func (_u *EntityUpdate) ClearFields() *EntityUpdate {
|
|
_u.mutation.ClearFields()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to EntityField entities by IDs.
|
|
func (_u *EntityUpdate) RemoveFieldIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to EntityField entities.
|
|
func (_u *EntityUpdate) RemoveFields(v ...*EntityField) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *EntityUpdate) ClearMaintenanceEntries() *EntityUpdate {
|
|
_u.mutation.ClearMaintenanceEntries()
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (_u *EntityUpdate) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (_u *EntityUpdate) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (_u *EntityUpdate) ClearAttachments() *EntityUpdate {
|
|
_u.mutation.ClearAttachments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (_u *EntityUpdate) RemoveAttachmentIDs(ids ...uuid.UUID) *EntityUpdate {
|
|
_u.mutation.RemoveAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (_u *EntityUpdate) RemoveAttachments(v ...*Attachment) *EntityUpdate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *EntityUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *EntityUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *EntityUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EntityUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *EntityUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := entity.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *EntityUpdate) check() error {
|
|
if v, ok := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Entity.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EntityUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(entity.Table, entity.Columns, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(entity.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(entity.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(entity.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ImportRef(); ok {
|
|
_spec.SetField(entity.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ImportRefCleared() {
|
|
_spec.ClearField(entity.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Notes(); ok {
|
|
_spec.SetField(entity.FieldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NotesCleared() {
|
|
_spec.ClearField(entity.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Insured(); ok {
|
|
_spec.SetField(entity.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Archived(); ok {
|
|
_spec.SetField(entity.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.AssetID(); ok {
|
|
_spec.SetField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SyncChildEntitiesLocations(); ok {
|
|
_spec.SetField(entity.FieldSyncChildEntitiesLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.SerialNumber(); ok {
|
|
_spec.SetField(entity.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(entity.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ModelNumber(); ok {
|
|
_spec.SetField(entity.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(entity.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Manufacturer(); ok {
|
|
_spec.SetField(entity.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(entity.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(entity.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(entity.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(entity.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if _u.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(entity.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(entity.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldTime(); ok {
|
|
_spec.SetField(entity.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(entity.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SoldTo(); ok {
|
|
_spec.SetField(entity.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldToCleared() {
|
|
_spec.ClearField(entity.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.SoldPrice(); ok {
|
|
_spec.SetField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldNotes(); ok {
|
|
_spec.SetField(entity.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(entity.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if _u.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 := _u.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 _u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 _u.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
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 := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
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 _u.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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 := _u.mutation.RemovedEntityIDs(); len(nodes) > 0 && !_u.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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 _u.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
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 := _u.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
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 _u.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 := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.mutation.TypeCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.TypeTable,
|
|
Columns: []string{entity.TypeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TypeIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.TypeTable,
|
|
Columns: []string{entity.TypeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.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 := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.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 := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.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 := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.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 := _u.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 _node, err = sqlgraph.UpdateNodes(ctx, _u.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
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, 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 (_u *EntityUpdateOne) SetUpdatedAt(v time.Time) *EntityUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *EntityUpdateOne) SetName(v string) *EntityUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableName(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDescription sets the "description" field.
|
|
func (_u *EntityUpdateOne) SetDescription(v string) *EntityUpdateOne {
|
|
_u.mutation.SetDescription(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableDescription(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetDescription(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
func (_u *EntityUpdateOne) ClearDescription() *EntityUpdateOne {
|
|
_u.mutation.ClearDescription()
|
|
return _u
|
|
}
|
|
|
|
// SetImportRef sets the "import_ref" field.
|
|
func (_u *EntityUpdateOne) SetImportRef(v string) *EntityUpdateOne {
|
|
_u.mutation.SetImportRef(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableImportRef sets the "import_ref" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableImportRef(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetImportRef(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearImportRef clears the value of the "import_ref" field.
|
|
func (_u *EntityUpdateOne) ClearImportRef() *EntityUpdateOne {
|
|
_u.mutation.ClearImportRef()
|
|
return _u
|
|
}
|
|
|
|
// SetNotes sets the "notes" field.
|
|
func (_u *EntityUpdateOne) SetNotes(v string) *EntityUpdateOne {
|
|
_u.mutation.SetNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableNotes sets the "notes" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableNotes(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearNotes clears the value of the "notes" field.
|
|
func (_u *EntityUpdateOne) ClearNotes() *EntityUpdateOne {
|
|
_u.mutation.ClearNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetQuantity sets the "quantity" field.
|
|
func (_u *EntityUpdateOne) SetQuantity(v int) *EntityUpdateOne {
|
|
_u.mutation.ResetQuantity()
|
|
_u.mutation.SetQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableQuantity sets the "quantity" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableQuantity(v *int) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetQuantity(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddQuantity adds value to the "quantity" field.
|
|
func (_u *EntityUpdateOne) AddQuantity(v int) *EntityUpdateOne {
|
|
_u.mutation.AddQuantity(v)
|
|
return _u
|
|
}
|
|
|
|
// SetInsured sets the "insured" field.
|
|
func (_u *EntityUpdateOne) SetInsured(v bool) *EntityUpdateOne {
|
|
_u.mutation.SetInsured(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableInsured sets the "insured" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableInsured(v *bool) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetInsured(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetArchived sets the "archived" field.
|
|
func (_u *EntityUpdateOne) SetArchived(v bool) *EntityUpdateOne {
|
|
_u.mutation.SetArchived(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableArchived sets the "archived" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableArchived(v *bool) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetArchived(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAssetID sets the "asset_id" field.
|
|
func (_u *EntityUpdateOne) SetAssetID(v int) *EntityUpdateOne {
|
|
_u.mutation.ResetAssetID()
|
|
_u.mutation.SetAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableAssetID(v *int) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetAssetID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddAssetID adds value to the "asset_id" field.
|
|
func (_u *EntityUpdateOne) AddAssetID(v int) *EntityUpdateOne {
|
|
_u.mutation.AddAssetID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSyncChildEntitiesLocations sets the "sync_child_entities_locations" field.
|
|
func (_u *EntityUpdateOne) SetSyncChildEntitiesLocations(v bool) *EntityUpdateOne {
|
|
_u.mutation.SetSyncChildEntitiesLocations(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSyncChildEntitiesLocations sets the "sync_child_entities_locations" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSyncChildEntitiesLocations(v *bool) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSyncChildEntitiesLocations(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetSerialNumber sets the "serial_number" field.
|
|
func (_u *EntityUpdateOne) SetSerialNumber(v string) *EntityUpdateOne {
|
|
_u.mutation.SetSerialNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSerialNumber sets the "serial_number" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSerialNumber(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSerialNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSerialNumber clears the value of the "serial_number" field.
|
|
func (_u *EntityUpdateOne) ClearSerialNumber() *EntityUpdateOne {
|
|
_u.mutation.ClearSerialNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetModelNumber sets the "model_number" field.
|
|
func (_u *EntityUpdateOne) SetModelNumber(v string) *EntityUpdateOne {
|
|
_u.mutation.SetModelNumber(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableModelNumber sets the "model_number" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableModelNumber(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetModelNumber(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearModelNumber clears the value of the "model_number" field.
|
|
func (_u *EntityUpdateOne) ClearModelNumber() *EntityUpdateOne {
|
|
_u.mutation.ClearModelNumber()
|
|
return _u
|
|
}
|
|
|
|
// SetManufacturer sets the "manufacturer" field.
|
|
func (_u *EntityUpdateOne) SetManufacturer(v string) *EntityUpdateOne {
|
|
_u.mutation.SetManufacturer(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableManufacturer sets the "manufacturer" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableManufacturer(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetManufacturer(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearManufacturer clears the value of the "manufacturer" field.
|
|
func (_u *EntityUpdateOne) ClearManufacturer() *EntityUpdateOne {
|
|
_u.mutation.ClearManufacturer()
|
|
return _u
|
|
}
|
|
|
|
// SetLifetimeWarranty sets the "lifetime_warranty" field.
|
|
func (_u *EntityUpdateOne) SetLifetimeWarranty(v bool) *EntityUpdateOne {
|
|
_u.mutation.SetLifetimeWarranty(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLifetimeWarranty sets the "lifetime_warranty" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableLifetimeWarranty(v *bool) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetLifetimeWarranty(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyExpires sets the "warranty_expires" field.
|
|
func (_u *EntityUpdateOne) SetWarrantyExpires(v time.Time) *EntityUpdateOne {
|
|
_u.mutation.SetWarrantyExpires(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyExpires sets the "warranty_expires" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableWarrantyExpires(v *time.Time) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetWarrantyExpires(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyExpires clears the value of the "warranty_expires" field.
|
|
func (_u *EntityUpdateOne) ClearWarrantyExpires() *EntityUpdateOne {
|
|
_u.mutation.ClearWarrantyExpires()
|
|
return _u
|
|
}
|
|
|
|
// SetWarrantyDetails sets the "warranty_details" field.
|
|
func (_u *EntityUpdateOne) SetWarrantyDetails(v string) *EntityUpdateOne {
|
|
_u.mutation.SetWarrantyDetails(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableWarrantyDetails sets the "warranty_details" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableWarrantyDetails(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetWarrantyDetails(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearWarrantyDetails clears the value of the "warranty_details" field.
|
|
func (_u *EntityUpdateOne) ClearWarrantyDetails() *EntityUpdateOne {
|
|
_u.mutation.ClearWarrantyDetails()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseTime sets the "purchase_time" field.
|
|
func (_u *EntityUpdateOne) SetPurchaseTime(v time.Time) *EntityUpdateOne {
|
|
_u.mutation.SetPurchaseTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseTime sets the "purchase_time" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillablePurchaseTime(v *time.Time) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchaseTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseTime clears the value of the "purchase_time" field.
|
|
func (_u *EntityUpdateOne) ClearPurchaseTime() *EntityUpdateOne {
|
|
_u.mutation.ClearPurchaseTime()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchaseFrom sets the "purchase_from" field.
|
|
func (_u *EntityUpdateOne) SetPurchaseFrom(v string) *EntityUpdateOne {
|
|
_u.mutation.SetPurchaseFrom(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchaseFrom sets the "purchase_from" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillablePurchaseFrom(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchaseFrom(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPurchaseFrom clears the value of the "purchase_from" field.
|
|
func (_u *EntityUpdateOne) ClearPurchaseFrom() *EntityUpdateOne {
|
|
_u.mutation.ClearPurchaseFrom()
|
|
return _u
|
|
}
|
|
|
|
// SetPurchasePrice sets the "purchase_price" field.
|
|
func (_u *EntityUpdateOne) SetPurchasePrice(v float64) *EntityUpdateOne {
|
|
_u.mutation.ResetPurchasePrice()
|
|
_u.mutation.SetPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePurchasePrice sets the "purchase_price" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillablePurchasePrice(v *float64) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetPurchasePrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddPurchasePrice adds value to the "purchase_price" field.
|
|
func (_u *EntityUpdateOne) AddPurchasePrice(v float64) *EntityUpdateOne {
|
|
_u.mutation.AddPurchasePrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTime sets the "sold_time" field.
|
|
func (_u *EntityUpdateOne) SetSoldTime(v time.Time) *EntityUpdateOne {
|
|
_u.mutation.SetSoldTime(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTime sets the "sold_time" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSoldTime(v *time.Time) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldTime(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTime clears the value of the "sold_time" field.
|
|
func (_u *EntityUpdateOne) ClearSoldTime() *EntityUpdateOne {
|
|
_u.mutation.ClearSoldTime()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldTo sets the "sold_to" field.
|
|
func (_u *EntityUpdateOne) SetSoldTo(v string) *EntityUpdateOne {
|
|
_u.mutation.SetSoldTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldTo sets the "sold_to" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSoldTo(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldTo clears the value of the "sold_to" field.
|
|
func (_u *EntityUpdateOne) ClearSoldTo() *EntityUpdateOne {
|
|
_u.mutation.ClearSoldTo()
|
|
return _u
|
|
}
|
|
|
|
// SetSoldPrice sets the "sold_price" field.
|
|
func (_u *EntityUpdateOne) SetSoldPrice(v float64) *EntityUpdateOne {
|
|
_u.mutation.ResetSoldPrice()
|
|
_u.mutation.SetSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldPrice sets the "sold_price" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSoldPrice(v *float64) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldPrice(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddSoldPrice adds value to the "sold_price" field.
|
|
func (_u *EntityUpdateOne) AddSoldPrice(v float64) *EntityUpdateOne {
|
|
_u.mutation.AddSoldPrice(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSoldNotes sets the "sold_notes" field.
|
|
func (_u *EntityUpdateOne) SetSoldNotes(v string) *EntityUpdateOne {
|
|
_u.mutation.SetSoldNotes(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSoldNotes sets the "sold_notes" field if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableSoldNotes(v *string) *EntityUpdateOne {
|
|
if v != nil {
|
|
_u.SetSoldNotes(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearSoldNotes clears the value of the "sold_notes" field.
|
|
func (_u *EntityUpdateOne) ClearSoldNotes() *EntityUpdateOne {
|
|
_u.mutation.ClearSoldNotes()
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group" edge to the Group entity by ID.
|
|
func (_u *EntityUpdateOne) SetGroupID(id uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.SetGroupID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *EntityUpdateOne) SetGroup(v *Group) *EntityUpdateOne {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// AddChildIDs adds the "children" edge to the Entity entity by IDs.
|
|
func (_u *EntityUpdateOne) AddChildIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddChildren adds the "children" edges to the Entity entity.
|
|
func (_u *EntityUpdateOne) AddChildren(v ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddChildIDs(ids...)
|
|
}
|
|
|
|
// SetParentID sets the "parent" edge to the Entity entity by ID.
|
|
func (_u *EntityUpdateOne) SetParentID(id uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.SetParentID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableParentID sets the "parent" edge to the Entity entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableParentID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetParentID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetParent sets the "parent" edge to the Entity entity.
|
|
func (_u *EntityUpdateOne) SetParent(v *Entity) *EntityUpdateOne {
|
|
return _u.SetParentID(v.ID)
|
|
}
|
|
|
|
// AddEntityIDs adds the "entity" edge to the Entity entity by IDs.
|
|
func (_u *EntityUpdateOne) AddEntityIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddEntityIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddEntity adds the "entity" edges to the Entity entity.
|
|
func (_u *EntityUpdateOne) AddEntity(v ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddEntityIDs(ids...)
|
|
}
|
|
|
|
// SetLocationID sets the "location" edge to the Entity entity by ID.
|
|
func (_u *EntityUpdateOne) SetLocationID(id uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.SetLocationID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableLocationID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetLocationID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLocation sets the "location" edge to the Entity entity.
|
|
func (_u *EntityUpdateOne) SetLocation(v *Entity) *EntityUpdateOne {
|
|
return _u.SetLocationID(v.ID)
|
|
}
|
|
|
|
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
|
func (_u *EntityUpdateOne) AddLabelIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddLabel adds the "label" edges to the Label entity.
|
|
func (_u *EntityUpdateOne) AddLabel(v ...*Label) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddLabelIDs(ids...)
|
|
}
|
|
|
|
// SetTypeID sets the "type" edge to the EntityType entity by ID.
|
|
func (_u *EntityUpdateOne) SetTypeID(id uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.SetTypeID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTypeID sets the "type" edge to the EntityType entity by ID if the given value is not nil.
|
|
func (_u *EntityUpdateOne) SetNillableTypeID(id *uuid.UUID) *EntityUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetTypeID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetType sets the "type" edge to the EntityType entity.
|
|
func (_u *EntityUpdateOne) SetType(v *EntityType) *EntityUpdateOne {
|
|
return _u.SetTypeID(v.ID)
|
|
}
|
|
|
|
// AddFieldIDs adds the "fields" edge to the EntityField entity by IDs.
|
|
func (_u *EntityUpdateOne) AddFieldIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddFields adds the "fields" edges to the EntityField entity.
|
|
func (_u *EntityUpdateOne) AddFields(v ...*EntityField) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddFieldIDs(ids...)
|
|
}
|
|
|
|
// AddMaintenanceEntryIDs adds the "maintenance_entries" edge to the MaintenanceEntry entity by IDs.
|
|
func (_u *EntityUpdateOne) AddMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddMaintenanceEntries adds the "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *EntityUpdateOne) AddMaintenanceEntries(v ...*MaintenanceEntry) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
|
func (_u *EntityUpdateOne) AddAttachmentIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.AddAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddAttachments adds the "attachments" edges to the Attachment entity.
|
|
func (_u *EntityUpdateOne) AddAttachments(v ...*Attachment) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the EntityMutation object of the builder.
|
|
func (_u *EntityUpdateOne) Mutation() *EntityMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *EntityUpdateOne) ClearGroup() *EntityUpdateOne {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearChildren clears all "children" edges to the Entity entity.
|
|
func (_u *EntityUpdateOne) ClearChildren() *EntityUpdateOne {
|
|
_u.mutation.ClearChildren()
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildIDs removes the "children" edge to Entity entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveChildIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveChildIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveChildren removes "children" edges to Entity entities.
|
|
func (_u *EntityUpdateOne) RemoveChildren(v ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveChildIDs(ids...)
|
|
}
|
|
|
|
// ClearParent clears the "parent" edge to the Entity entity.
|
|
func (_u *EntityUpdateOne) ClearParent() *EntityUpdateOne {
|
|
_u.mutation.ClearParent()
|
|
return _u
|
|
}
|
|
|
|
// ClearEntity clears all "entity" edges to the Entity entity.
|
|
func (_u *EntityUpdateOne) ClearEntity() *EntityUpdateOne {
|
|
_u.mutation.ClearEntity()
|
|
return _u
|
|
}
|
|
|
|
// RemoveEntityIDs removes the "entity" edge to Entity entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveEntityIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveEntity removes "entity" edges to Entity entities.
|
|
func (_u *EntityUpdateOne) RemoveEntity(v ...*Entity) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveEntityIDs(ids...)
|
|
}
|
|
|
|
// ClearLocation clears the "location" edge to the Entity entity.
|
|
func (_u *EntityUpdateOne) ClearLocation() *EntityUpdateOne {
|
|
_u.mutation.ClearLocation()
|
|
return _u
|
|
}
|
|
|
|
// ClearLabel clears all "label" edges to the Label entity.
|
|
func (_u *EntityUpdateOne) ClearLabel() *EntityUpdateOne {
|
|
_u.mutation.ClearLabel()
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveLabelIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveLabel removes "label" edges to Label entities.
|
|
func (_u *EntityUpdateOne) RemoveLabel(v ...*Label) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveLabelIDs(ids...)
|
|
}
|
|
|
|
// ClearType clears the "type" edge to the EntityType entity.
|
|
func (_u *EntityUpdateOne) ClearType() *EntityUpdateOne {
|
|
_u.mutation.ClearType()
|
|
return _u
|
|
}
|
|
|
|
// ClearFields clears all "fields" edges to the EntityField entity.
|
|
func (_u *EntityUpdateOne) ClearFields() *EntityUpdateOne {
|
|
_u.mutation.ClearFields()
|
|
return _u
|
|
}
|
|
|
|
// RemoveFieldIDs removes the "fields" edge to EntityField entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveFieldIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveFieldIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveFields removes "fields" edges to EntityField entities.
|
|
func (_u *EntityUpdateOne) RemoveFields(v ...*EntityField) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveFieldIDs(ids...)
|
|
}
|
|
|
|
// ClearMaintenanceEntries clears all "maintenance_entries" edges to the MaintenanceEntry entity.
|
|
func (_u *EntityUpdateOne) ClearMaintenanceEntries() *EntityUpdateOne {
|
|
_u.mutation.ClearMaintenanceEntries()
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntryIDs removes the "maintenance_entries" edge to MaintenanceEntry entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveMaintenanceEntryIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveMaintenanceEntryIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveMaintenanceEntries removes "maintenance_entries" edges to MaintenanceEntry entities.
|
|
func (_u *EntityUpdateOne) RemoveMaintenanceEntries(v ...*MaintenanceEntry) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveMaintenanceEntryIDs(ids...)
|
|
}
|
|
|
|
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
|
func (_u *EntityUpdateOne) ClearAttachments() *EntityUpdateOne {
|
|
_u.mutation.ClearAttachments()
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachmentIDs removes the "attachments" edge to Attachment entities by IDs.
|
|
func (_u *EntityUpdateOne) RemoveAttachmentIDs(ids ...uuid.UUID) *EntityUpdateOne {
|
|
_u.mutation.RemoveAttachmentIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveAttachments removes "attachments" edges to Attachment entities.
|
|
func (_u *EntityUpdateOne) RemoveAttachments(v ...*Attachment) *EntityUpdateOne {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveAttachmentIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the EntityUpdate builder.
|
|
func (_u *EntityUpdateOne) Where(ps ...predicate.Entity) *EntityUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *EntityUpdateOne) Select(field string, fields ...string) *EntityUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Entity entity.
|
|
func (_u *EntityUpdateOne) Save(ctx context.Context) (*Entity, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *EntityUpdateOne) SaveX(ctx context.Context) *Entity {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *EntityUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *EntityUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *EntityUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := entity.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *EntityUpdateOne) check() error {
|
|
if v, ok := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 := _u.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 _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Entity.group"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *EntityUpdateOne) sqlSave(ctx context.Context) (_node *Entity, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(entity.Table, entity.Columns, sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID))
|
|
id, ok := _u.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 := _u.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 := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(entity.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(entity.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Description(); ok {
|
|
_spec.SetField(entity.FieldDescription, field.TypeString, value)
|
|
}
|
|
if _u.mutation.DescriptionCleared() {
|
|
_spec.ClearField(entity.FieldDescription, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ImportRef(); ok {
|
|
_spec.SetField(entity.FieldImportRef, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ImportRefCleared() {
|
|
_spec.ClearField(entity.FieldImportRef, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Notes(); ok {
|
|
_spec.SetField(entity.FieldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.NotesCleared() {
|
|
_spec.ClearField(entity.FieldNotes, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Quantity(); ok {
|
|
_spec.SetField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedQuantity(); ok {
|
|
_spec.AddField(entity.FieldQuantity, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.Insured(); ok {
|
|
_spec.SetField(entity.FieldInsured, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Archived(); ok {
|
|
_spec.SetField(entity.FieldArchived, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.AssetID(); ok {
|
|
_spec.SetField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedAssetID(); ok {
|
|
_spec.AddField(entity.FieldAssetID, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.SyncChildEntitiesLocations(); ok {
|
|
_spec.SetField(entity.FieldSyncChildEntitiesLocations, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.SerialNumber(); ok {
|
|
_spec.SetField(entity.FieldSerialNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SerialNumberCleared() {
|
|
_spec.ClearField(entity.FieldSerialNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.ModelNumber(); ok {
|
|
_spec.SetField(entity.FieldModelNumber, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ModelNumberCleared() {
|
|
_spec.ClearField(entity.FieldModelNumber, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Manufacturer(); ok {
|
|
_spec.SetField(entity.FieldManufacturer, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ManufacturerCleared() {
|
|
_spec.ClearField(entity.FieldManufacturer, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.LifetimeWarranty(); ok {
|
|
_spec.SetField(entity.FieldLifetimeWarranty, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyExpires(); ok {
|
|
_spec.SetField(entity.FieldWarrantyExpires, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.WarrantyExpiresCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyExpires, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.WarrantyDetails(); ok {
|
|
_spec.SetField(entity.FieldWarrantyDetails, field.TypeString, value)
|
|
}
|
|
if _u.mutation.WarrantyDetailsCleared() {
|
|
_spec.ClearField(entity.FieldWarrantyDetails, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseTime(); ok {
|
|
_spec.SetField(entity.FieldPurchaseTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PurchaseTimeCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PurchaseFrom(); ok {
|
|
_spec.SetField(entity.FieldPurchaseFrom, field.TypeString, value)
|
|
}
|
|
if _u.mutation.PurchaseFromCleared() {
|
|
_spec.ClearField(entity.FieldPurchaseFrom, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.PurchasePrice(); ok {
|
|
_spec.SetField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedPurchasePrice(); ok {
|
|
_spec.AddField(entity.FieldPurchasePrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldTime(); ok {
|
|
_spec.SetField(entity.FieldSoldTime, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.SoldTimeCleared() {
|
|
_spec.ClearField(entity.FieldSoldTime, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.SoldTo(); ok {
|
|
_spec.SetField(entity.FieldSoldTo, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldToCleared() {
|
|
_spec.ClearField(entity.FieldSoldTo, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.SoldPrice(); ok {
|
|
_spec.SetField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedSoldPrice(); ok {
|
|
_spec.AddField(entity.FieldSoldPrice, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.SoldNotes(); ok {
|
|
_spec.SetField(entity.FieldSoldNotes, field.TypeString, value)
|
|
}
|
|
if _u.mutation.SoldNotesCleared() {
|
|
_spec.ClearField(entity.FieldSoldNotes, field.TypeString)
|
|
}
|
|
if _u.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 := _u.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 _u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
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 _u.mutation.ParentCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
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 := _u.mutation.ParentIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: false,
|
|
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 _u.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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 := _u.mutation.RemovedEntityIDs(); len(nodes) > 0 && !_u.mutation.EntityCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
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 _u.mutation.LocationCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
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 := _u.mutation.LocationIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
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 _u.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 := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.mutation.TypeCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.TypeTable,
|
|
Columns: []string{entity.TypeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TypeIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: entity.TypeTable,
|
|
Columns: []string{entity.TypeColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.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 := _u.mutation.RemovedFieldsIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.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 := _u.mutation.RemovedMaintenanceEntriesIDs(); len(nodes) > 0 && !_u.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 := _u.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 _u.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 := _u.mutation.RemovedAttachmentsIDs(); len(nodes) > 0 && !_u.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 := _u.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: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.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
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|