forked from mirrors/homebox
feat: asset tags/ids (#142)
* add schema * run db migration * bulk seed asset IDs * breaking: update runtime options * conditionally increment asset IDs * update API endpoints * fix import asset id assignment * refactor display + marshal/unmarshal * add docs page * add to form field * hide 000-000 values * update ENV vars
This commit is contained in:
parent
976f68252d
commit
6dc2ae1bea
32 changed files with 905 additions and 72 deletions
|
@ -135,6 +135,27 @@ func (iu *ItemUpdate) SetNillableArchived(b *bool) *ItemUpdate {
|
|||
return iu
|
||||
}
|
||||
|
||||
// SetAssetID sets the "asset_id" field.
|
||||
func (iu *ItemUpdate) SetAssetID(i int) *ItemUpdate {
|
||||
iu.mutation.ResetAssetID()
|
||||
iu.mutation.SetAssetID(i)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
||||
func (iu *ItemUpdate) SetNillableAssetID(i *int) *ItemUpdate {
|
||||
if i != nil {
|
||||
iu.SetAssetID(*i)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// AddAssetID adds i to the "asset_id" field.
|
||||
func (iu *ItemUpdate) AddAssetID(i int) *ItemUpdate {
|
||||
iu.mutation.AddAssetID(i)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetSerialNumber sets the "serial_number" field.
|
||||
func (iu *ItemUpdate) SetSerialNumber(s string) *ItemUpdate {
|
||||
iu.mutation.SetSerialNumber(s)
|
||||
|
@ -816,6 +837,20 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
Column: item.FieldArchived,
|
||||
})
|
||||
}
|
||||
if value, ok := iu.mutation.AssetID(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
}
|
||||
if value, ok := iu.mutation.AddedAssetID(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
}
|
||||
if value, ok := iu.mutation.SerialNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
|
@ -1422,6 +1457,27 @@ func (iuo *ItemUpdateOne) SetNillableArchived(b *bool) *ItemUpdateOne {
|
|||
return iuo
|
||||
}
|
||||
|
||||
// SetAssetID sets the "asset_id" field.
|
||||
func (iuo *ItemUpdateOne) SetAssetID(i int) *ItemUpdateOne {
|
||||
iuo.mutation.ResetAssetID()
|
||||
iuo.mutation.SetAssetID(i)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableAssetID sets the "asset_id" field if the given value is not nil.
|
||||
func (iuo *ItemUpdateOne) SetNillableAssetID(i *int) *ItemUpdateOne {
|
||||
if i != nil {
|
||||
iuo.SetAssetID(*i)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// AddAssetID adds i to the "asset_id" field.
|
||||
func (iuo *ItemUpdateOne) AddAssetID(i int) *ItemUpdateOne {
|
||||
iuo.mutation.AddAssetID(i)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetSerialNumber sets the "serial_number" field.
|
||||
func (iuo *ItemUpdateOne) SetSerialNumber(s string) *ItemUpdateOne {
|
||||
iuo.mutation.SetSerialNumber(s)
|
||||
|
@ -2133,6 +2189,20 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
Column: item.FieldArchived,
|
||||
})
|
||||
}
|
||||
if value, ok := iuo.mutation.AssetID(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedAssetID(); ok {
|
||||
_spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeInt,
|
||||
Value: value,
|
||||
Column: item.FieldAssetID,
|
||||
})
|
||||
}
|
||||
if value, ok := iuo.mutation.SerialNumber(); ok {
|
||||
_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{
|
||||
Type: field.TypeString,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue