Finish merge stuff with main

This commit is contained in:
Matthew Kilgore
2025-12-13 21:23:45 -05:00
parent 44f488db77
commit 798426bebf
49 changed files with 14356 additions and 9405 deletions

View File

@@ -11,7 +11,7 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
)
// Attachment is the model entity for the Attachment schema.
@@ -37,14 +37,14 @@ type Attachment struct {
// The values are being populated by the AttachmentQuery when eager-loading is set.
Edges AttachmentEdges `json:"edges"`
attachment_thumbnail *uuid.UUID
item_attachments *uuid.UUID
entity_attachments *uuid.UUID
selectValues sql.SelectValues
}
// AttachmentEdges holds the relations/edges for other nodes in the graph.
type AttachmentEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// Thumbnail holds the value of the thumbnail edge.
Thumbnail *Attachment `json:"thumbnail,omitempty"`
// loadedTypes holds the information for reporting if a
@@ -52,15 +52,15 @@ type AttachmentEdges struct {
loadedTypes [2]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AttachmentEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e AttachmentEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// ThumbnailOrErr returns the Thumbnail value or an error if the edge
@@ -89,7 +89,7 @@ func (*Attachment) scanValues(columns []string) ([]any, error) {
values[i] = new(uuid.UUID)
case attachment.ForeignKeys[0]: // attachment_thumbnail
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
case attachment.ForeignKeys[1]: // item_attachments
case attachment.ForeignKeys[1]: // entity_attachments
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -163,10 +163,10 @@ func (_m *Attachment) assignValues(columns []string, values []any) error {
}
case attachment.ForeignKeys[1]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field item_attachments", values[i])
return fmt.Errorf("unexpected type %T for field entity_attachments", values[i])
} else if value.Valid {
_m.item_attachments = new(uuid.UUID)
*_m.item_attachments = *value.S.(*uuid.UUID)
_m.entity_attachments = new(uuid.UUID)
*_m.entity_attachments = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -181,9 +181,9 @@ func (_m *Attachment) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the Attachment entity.
func (_m *Attachment) QueryItem() *ItemQuery {
return NewAttachmentClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the Attachment entity.
func (_m *Attachment) QueryEntity() *EntityQuery {
return NewAttachmentClient(_m.config).QueryEntity(_m)
}
// QueryThumbnail queries the "thumbnail" edge of the Attachment entity.

View File

@@ -12,7 +12,7 @@ import (
"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/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
)
// AttachmentCreate is the builder for creating a Attachment entity.
@@ -134,23 +134,23 @@ func (_c *AttachmentCreate) SetNillableID(v *uuid.UUID) *AttachmentCreate {
return _c
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_c *AttachmentCreate) SetItemID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_c *AttachmentCreate) SetEntityID(id uuid.UUID) *AttachmentCreate {
_c.mutation.SetEntityID(id)
return _c
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_c *AttachmentCreate) SetNillableItemID(id *uuid.UUID) *AttachmentCreate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_c *AttachmentCreate) SetNillableEntityID(id *uuid.UUID) *AttachmentCreate {
if id != nil {
_c = _c.SetItemID(*id)
_c = _c.SetEntityID(*id)
}
return _c
}
// SetItem sets the "item" edge to the Item entity.
func (_c *AttachmentCreate) SetItem(v *Item) *AttachmentCreate {
return _c.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *AttachmentCreate) SetEntity(v *Entity) *AttachmentCreate {
return _c.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -332,21 +332,21 @@ func (_c *AttachmentCreate) createSpec() (*Attachment, *sqlgraph.CreateSpec) {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
_node.MimeType = value
}
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.item_attachments = &nodes[0]
_node.entity_attachments = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ThumbnailIDs(); len(nodes) > 0 {

View File

@@ -13,7 +13,7 @@ import (
"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/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -24,7 +24,7 @@ type AttachmentQuery struct {
order []attachment.OrderOption
inters []Interceptor
predicates []predicate.Attachment
withItem *ItemQuery
withEntity *EntityQuery
withThumbnail *AttachmentQuery
withFKs bool
// intermediate query (i.e. traversal path).
@@ -63,9 +63,9 @@ func (_q *AttachmentQuery) Order(o ...attachment.OrderOption) *AttachmentQuery {
return _q
}
// QueryItem chains the current query on the "item" edge.
func (_q *AttachmentQuery) QueryItem() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntity chains the current query on the "entity" edge.
func (_q *AttachmentQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -76,8 +76,8 @@ func (_q *AttachmentQuery) QueryItem() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(attachment.Table, attachment.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.ItemTable, attachment.ItemColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, attachment.EntityTable, attachment.EntityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -299,7 +299,7 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery {
order: append([]attachment.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Attachment{}, _q.predicates...),
withItem: _q.withItem.Clone(),
withEntity: _q.withEntity.Clone(),
withThumbnail: _q.withThumbnail.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
@@ -307,14 +307,14 @@ func (_q *AttachmentQuery) Clone() *AttachmentQuery {
}
}
// WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AttachmentQuery) WithItem(opts ...func(*ItemQuery)) *AttachmentQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntity tells the query-builder to eager-load the nodes that are connected to
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AttachmentQuery) WithEntity(opts ...func(*EntityQuery)) *AttachmentQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItem = query
_q.withEntity = query
return _q
}
@@ -409,11 +409,11 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
withFKs = _q.withFKs
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withItem != nil,
_q.withEntity != nil,
_q.withThumbnail != nil,
}
)
if _q.withItem != nil || _q.withThumbnail != nil {
if _q.withEntity != nil || _q.withThumbnail != nil {
withFKs = true
}
if withFKs {
@@ -437,9 +437,9 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withItem; query != nil {
if err := _q.loadItem(ctx, query, nodes, nil,
func(n *Attachment, e *Item) { n.Edges.Item = e }); err != nil {
if query := _q.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *Attachment, e *Entity) { n.Edges.Entity = e }); err != nil {
return nil, err
}
}
@@ -452,14 +452,14 @@ func (_q *AttachmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*A
return nodes, nil
}
func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Item)) error {
func (_q *AttachmentQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*Attachment, init func(*Attachment), assign func(*Attachment, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*Attachment)
for i := range nodes {
if nodes[i].item_attachments == nil {
if nodes[i].entity_attachments == nil {
continue
}
fk := *nodes[i].item_attachments
fk := *nodes[i].entity_attachments
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -468,7 +468,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
if len(ids) == 0 {
return nil
}
query.Where(item.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -476,7 +476,7 @@ func (_q *AttachmentQuery) loadItem(ctx context.Context, query *ItemQuery, nodes
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "item_attachments" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "entity_attachments" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)

View File

@@ -13,7 +13,7 @@ import (
"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/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -106,23 +106,23 @@ func (_u *AttachmentUpdate) SetNillableMimeType(v *string) *AttachmentUpdate {
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdate) SetItemID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdate) SetEntityID(id uuid.UUID) *AttachmentUpdate {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableItemID(id *uuid.UUID) *AttachmentUpdate {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *AttachmentUpdate) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdate {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdate) SetItem(v *Item) *AttachmentUpdate {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) SetEntity(v *Entity) *AttachmentUpdate {
return _u.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -149,9 +149,9 @@ func (_u *AttachmentUpdate) Mutation() *AttachmentMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdate) ClearItem() *AttachmentUpdate {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdate) ClearEntity() *AttachmentUpdate {
_u.mutation.ClearEntity()
return _u
}
@@ -237,28 +237,28 @@ func (_u *AttachmentUpdate) sqlSave(ctx context.Context) (_node int, err error)
if value, ok := _u.mutation.MimeType(); ok {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -391,23 +391,23 @@ func (_u *AttachmentUpdateOne) SetNillableMimeType(v *string) *AttachmentUpdateO
return _u
}
// SetItemID sets the "item" edge to the Item entity by ID.
func (_u *AttachmentUpdateOne) SetItemID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetItemID(id)
// SetEntityID sets the "entity" edge to the Entity entity by ID.
func (_u *AttachmentUpdateOne) SetEntityID(id uuid.UUID) *AttachmentUpdateOne {
_u.mutation.SetEntityID(id)
return _u
}
// SetNillableItemID sets the "item" edge to the Item entity by ID if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableItemID(id *uuid.UUID) *AttachmentUpdateOne {
// SetNillableEntityID sets the "entity" edge to the Entity entity by ID if the given value is not nil.
func (_u *AttachmentUpdateOne) SetNillableEntityID(id *uuid.UUID) *AttachmentUpdateOne {
if id != nil {
_u = _u.SetItemID(*id)
_u = _u.SetEntityID(*id)
}
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) SetItem(v *Item) *AttachmentUpdateOne {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) SetEntity(v *Entity) *AttachmentUpdateOne {
return _u.SetEntityID(v.ID)
}
// SetThumbnailID sets the "thumbnail" edge to the Attachment entity by ID.
@@ -434,9 +434,9 @@ func (_u *AttachmentUpdateOne) Mutation() *AttachmentMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *AttachmentUpdateOne) ClearItem() *AttachmentUpdateOne {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *AttachmentUpdateOne) ClearEntity() *AttachmentUpdateOne {
_u.mutation.ClearEntity()
return _u
}
@@ -552,28 +552,28 @@ func (_u *AttachmentUpdateOne) sqlSave(ctx context.Context) (_node *Attachment,
if value, ok := _u.mutation.MimeType(); ok {
_spec.SetField(attachment.FieldMimeType, field.TypeString, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: attachment.ItemTable,
Columns: []string{attachment.ItemColumn},
Table: attachment.EntityTable,
Columns: []string{attachment.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

File diff suppressed because it is too large Load Diff

View File

@@ -15,13 +15,13 @@ import (
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authroles"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
"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/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
@@ -89,13 +89,13 @@ func checkColumn(t, c string) error {
attachment.Table: attachment.ValidColumn,
authroles.Table: authroles.ValidColumn,
authtokens.Table: authtokens.ValidColumn,
entity.Table: entity.ValidColumn,
entityfield.Table: entityfield.ValidColumn,
entitytype.Table: entitytype.ValidColumn,
group.Table: group.ValidColumn,
groupinvitationtoken.Table: groupinvitationtoken.ValidColumn,
item.Table: item.ValidColumn,
itemfield.Table: itemfield.ValidColumn,
itemtemplate.Table: itemtemplate.ValidColumn,
label.Table: label.ValidColumn,
location.Table: location.ValidColumn,
maintenanceentry.Table: maintenanceentry.ValidColumn,
notifier.Table: notifier.ValidColumn,
templatefield.Table: templatefield.ValidColumn,

View File

@@ -10,12 +10,12 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entityfield"
)
// ItemField is the model entity for the ItemField schema.
type ItemField struct {
// EntityField is the model entity for the EntityField schema.
type EntityField struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
@@ -28,7 +28,7 @@ type ItemField struct {
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Type holds the value of the "type" field.
Type itemfield.Type `json:"type,omitempty"`
Type entityfield.Type `json:"type,omitempty"`
// TextValue holds the value of the "text_value" field.
TextValue string `json:"text_value,omitempty"`
// NumberValue holds the value of the "number_value" field.
@@ -38,48 +38,48 @@ type ItemField struct {
// TimeValue holds the value of the "time_value" field.
TimeValue time.Time `json:"time_value,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ItemFieldQuery when eager-loading is set.
Edges ItemFieldEdges `json:"edges"`
item_fields *uuid.UUID
selectValues sql.SelectValues
// The values are being populated by the EntityFieldQuery when eager-loading is set.
Edges EntityFieldEdges `json:"edges"`
entity_fields *uuid.UUID
selectValues sql.SelectValues
}
// ItemFieldEdges holds the relations/edges for other nodes in the graph.
type ItemFieldEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// EntityFieldEdges holds the relations/edges for other nodes in the graph.
type EntityFieldEdges struct {
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemFieldEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e EntityFieldEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ItemField) scanValues(columns []string) ([]any, error) {
func (*EntityField) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case itemfield.FieldBooleanValue:
case entityfield.FieldBooleanValue:
values[i] = new(sql.NullBool)
case itemfield.FieldNumberValue:
case entityfield.FieldNumberValue:
values[i] = new(sql.NullInt64)
case itemfield.FieldName, itemfield.FieldDescription, itemfield.FieldType, itemfield.FieldTextValue:
case entityfield.FieldName, entityfield.FieldDescription, entityfield.FieldType, entityfield.FieldTextValue:
values[i] = new(sql.NullString)
case itemfield.FieldCreatedAt, itemfield.FieldUpdatedAt, itemfield.FieldTimeValue:
case entityfield.FieldCreatedAt, entityfield.FieldUpdatedAt, entityfield.FieldTimeValue:
values[i] = new(sql.NullTime)
case itemfield.FieldID:
case entityfield.FieldID:
values[i] = new(uuid.UUID)
case itemfield.ForeignKeys[0]: // item_fields
case entityfield.ForeignKeys[0]: // entity_fields
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
default:
values[i] = new(sql.UnknownType)
@@ -89,79 +89,79 @@ func (*ItemField) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ItemField fields.
func (_m *ItemField) assignValues(columns []string, values []any) error {
// to the EntityField fields.
func (_m *EntityField) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case itemfield.FieldID:
case entityfield.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case itemfield.FieldCreatedAt:
case entityfield.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case itemfield.FieldUpdatedAt:
case entityfield.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case itemfield.FieldName:
case entityfield.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case itemfield.FieldDescription:
case entityfield.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case itemfield.FieldType:
case entityfield.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = itemfield.Type(value.String)
_m.Type = entityfield.Type(value.String)
}
case itemfield.FieldTextValue:
case entityfield.FieldTextValue:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field text_value", values[i])
} else if value.Valid {
_m.TextValue = value.String
}
case itemfield.FieldNumberValue:
case entityfield.FieldNumberValue:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field number_value", values[i])
} else if value.Valid {
_m.NumberValue = int(value.Int64)
}
case itemfield.FieldBooleanValue:
case entityfield.FieldBooleanValue:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field boolean_value", values[i])
} else if value.Valid {
_m.BooleanValue = value.Bool
}
case itemfield.FieldTimeValue:
case entityfield.FieldTimeValue:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field time_value", values[i])
} else if value.Valid {
_m.TimeValue = value.Time
}
case itemfield.ForeignKeys[0]:
case entityfield.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field item_fields", values[i])
return fmt.Errorf("unexpected type %T for field entity_fields", values[i])
} else if value.Valid {
_m.item_fields = new(uuid.UUID)
*_m.item_fields = *value.S.(*uuid.UUID)
_m.entity_fields = new(uuid.UUID)
*_m.entity_fields = *value.S.(*uuid.UUID)
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -170,39 +170,39 @@ func (_m *ItemField) assignValues(columns []string, values []any) error {
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ItemField.
// Value returns the ent.Value that was dynamically selected and assigned to the EntityField.
// This includes values selected through modifiers, order, etc.
func (_m *ItemField) Value(name string) (ent.Value, error) {
func (_m *EntityField) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the ItemField entity.
func (_m *ItemField) QueryItem() *ItemQuery {
return NewItemFieldClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the EntityField entity.
func (_m *EntityField) QueryEntity() *EntityQuery {
return NewEntityFieldClient(_m.config).QueryEntity(_m)
}
// Update returns a builder for updating this ItemField.
// Note that you need to call ItemField.Unwrap() before calling this method if this ItemField
// Update returns a builder for updating this EntityField.
// Note that you need to call EntityField.Unwrap() before calling this method if this EntityField
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *ItemField) Update() *ItemFieldUpdateOne {
return NewItemFieldClient(_m.config).UpdateOne(_m)
func (_m *EntityField) Update() *EntityFieldUpdateOne {
return NewEntityFieldClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the ItemField entity that was returned from a transaction after it was closed,
// Unwrap unwraps the EntityField entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *ItemField) Unwrap() *ItemField {
func (_m *EntityField) Unwrap() *EntityField {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: ItemField is not a transactional entity")
panic("ent: EntityField is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *ItemField) String() string {
func (_m *EntityField) String() string {
var builder strings.Builder
builder.WriteString("ItemField(")
builder.WriteString("EntityField(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
@@ -234,5 +234,5 @@ func (_m *ItemField) String() string {
return builder.String()
}
// ItemFields is a parsable slice of ItemField.
type ItemFields []*ItemField
// EntityFields is a parsable slice of EntityField.
type EntityFields []*EntityField

View File

@@ -36,16 +36,16 @@ type Group struct {
type GroupEdges struct {
// Users holds the value of the users edge.
Users []*User `json:"users,omitempty"`
// Locations holds the value of the locations edge.
Locations []*Location `json:"locations,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// Labels holds the value of the labels edge.
Labels []*Label `json:"labels,omitempty"`
// InvitationTokens holds the value of the invitation_tokens edge.
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
// Notifiers holds the value of the notifiers edge.
Notifiers []*Notifier `json:"notifiers,omitempty"`
// EntityTypes holds the value of the entity_types edge.
EntityTypes []*EntityType `json:"entity_types,omitempty"`
// ItemTemplates holds the value of the item_templates edge.
ItemTemplates []*ItemTemplate `json:"item_templates,omitempty"`
// loadedTypes holds the information for reporting if a
@@ -62,28 +62,19 @@ func (e GroupEdges) UsersOrErr() ([]*User, error) {
return nil, &NotLoadedError{edge: "users"}
}
// LocationsOrErr returns the Locations value or an error if the edge
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) LocationsOrErr() ([]*Location, error) {
func (e GroupEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Locations, nil
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "locations"}
}
// ItemsOrErr returns the Items value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) ItemsOrErr() ([]*Item, error) {
if e.loadedTypes[2] {
return e.Items, nil
}
return nil, &NotLoadedError{edge: "items"}
return nil, &NotLoadedError{edge: "entities"}
}
// LabelsOrErr returns the Labels value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
if e.loadedTypes[3] {
if e.loadedTypes[2] {
return e.Labels, nil
}
return nil, &NotLoadedError{edge: "labels"}
@@ -92,7 +83,7 @@ func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
// InvitationTokensOrErr returns the InvitationTokens value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) {
if e.loadedTypes[4] {
if e.loadedTypes[3] {
return e.InvitationTokens, nil
}
return nil, &NotLoadedError{edge: "invitation_tokens"}
@@ -101,12 +92,21 @@ func (e GroupEdges) InvitationTokensOrErr() ([]*GroupInvitationToken, error) {
// NotifiersOrErr returns the Notifiers value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) NotifiersOrErr() ([]*Notifier, error) {
if e.loadedTypes[5] {
if e.loadedTypes[4] {
return e.Notifiers, nil
}
return nil, &NotLoadedError{edge: "notifiers"}
}
// EntityTypesOrErr returns the EntityTypes value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) EntityTypesOrErr() ([]*EntityType, error) {
if e.loadedTypes[5] {
return e.EntityTypes, nil
}
return nil, &NotLoadedError{edge: "entity_types"}
}
// ItemTemplatesOrErr returns the ItemTemplates value or an error if the edge
// was not loaded in eager-loading.
func (e GroupEdges) ItemTemplatesOrErr() ([]*ItemTemplate, error) {
@@ -190,14 +190,9 @@ func (_m *Group) QueryUsers() *UserQuery {
return NewGroupClient(_m.config).QueryUsers(_m)
}
// QueryLocations queries the "locations" edge of the Group entity.
func (_m *Group) QueryLocations() *LocationQuery {
return NewGroupClient(_m.config).QueryLocations(_m)
}
// QueryItems queries the "items" edge of the Group entity.
func (_m *Group) QueryItems() *ItemQuery {
return NewGroupClient(_m.config).QueryItems(_m)
// QueryEntities queries the "entities" edge of the Group entity.
func (_m *Group) QueryEntities() *EntityQuery {
return NewGroupClient(_m.config).QueryEntities(_m)
}
// QueryLabels queries the "labels" edge of the Group entity.
@@ -215,6 +210,11 @@ func (_m *Group) QueryNotifiers() *NotifierQuery {
return NewGroupClient(_m.config).QueryNotifiers(_m)
}
// QueryEntityTypes queries the "entity_types" edge of the Group entity.
func (_m *Group) QueryEntityTypes() *EntityTypeQuery {
return NewGroupClient(_m.config).QueryEntityTypes(_m)
}
// QueryItemTemplates queries the "item_templates" edge of the Group entity.
func (_m *Group) QueryItemTemplates() *ItemTemplateQuery {
return NewGroupClient(_m.config).QueryItemTemplates(_m)

View File

@@ -25,16 +25,16 @@ const (
FieldCurrency = "currency"
// EdgeUsers holds the string denoting the users edge name in mutations.
EdgeUsers = "users"
// EdgeLocations holds the string denoting the locations edge name in mutations.
EdgeLocations = "locations"
// EdgeItems holds the string denoting the items edge name in mutations.
EdgeItems = "items"
// EdgeEntities holds the string denoting the entities edge name in mutations.
EdgeEntities = "entities"
// EdgeLabels holds the string denoting the labels edge name in mutations.
EdgeLabels = "labels"
// EdgeInvitationTokens holds the string denoting the invitation_tokens edge name in mutations.
EdgeInvitationTokens = "invitation_tokens"
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
EdgeNotifiers = "notifiers"
// EdgeEntityTypes holds the string denoting the entity_types edge name in mutations.
EdgeEntityTypes = "entity_types"
// EdgeItemTemplates holds the string denoting the item_templates edge name in mutations.
EdgeItemTemplates = "item_templates"
// Table holds the table name of the group in the database.
@@ -46,20 +46,13 @@ const (
UsersInverseTable = "users"
// UsersColumn is the table column denoting the users relation/edge.
UsersColumn = "group_users"
// LocationsTable is the table that holds the locations relation/edge.
LocationsTable = "locations"
// LocationsInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationsInverseTable = "locations"
// LocationsColumn is the table column denoting the locations relation/edge.
LocationsColumn = "group_locations"
// ItemsTable is the table that holds the items relation/edge.
ItemsTable = "items"
// ItemsInverseTable is the table name for the Item entity.
// It exists in this package in order to avoid circular dependency with the "item" package.
ItemsInverseTable = "items"
// ItemsColumn is the table column denoting the items relation/edge.
ItemsColumn = "group_items"
// EntitiesTable is the table that holds the entities relation/edge.
EntitiesTable = "entities"
// EntitiesInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
EntitiesInverseTable = "entities"
// EntitiesColumn is the table column denoting the entities relation/edge.
EntitiesColumn = "group_entities"
// LabelsTable is the table that holds the labels relation/edge.
LabelsTable = "labels"
// LabelsInverseTable is the table name for the Label entity.
@@ -81,6 +74,13 @@ const (
NotifiersInverseTable = "notifiers"
// NotifiersColumn is the table column denoting the notifiers relation/edge.
NotifiersColumn = "group_id"
// EntityTypesTable is the table that holds the entity_types relation/edge.
EntityTypesTable = "entity_types"
// EntityTypesInverseTable is the table name for the EntityType entity.
// It exists in this package in order to avoid circular dependency with the "entitytype" package.
EntityTypesInverseTable = "entity_types"
// EntityTypesColumn is the table column denoting the entity_types relation/edge.
EntityTypesColumn = "group_entity_types"
// ItemTemplatesTable is the table that holds the item_templates relation/edge.
ItemTemplatesTable = "item_templates"
// ItemTemplatesInverseTable is the table name for the ItemTemplate entity.
@@ -166,31 +166,17 @@ func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByLocationsCount orders the results by locations count.
func ByLocationsCount(opts ...sql.OrderTermOption) OrderOption {
// ByEntitiesCount orders the results by entities count.
func ByEntitiesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newLocationsStep(), opts...)
sqlgraph.OrderByNeighborsCount(s, newEntitiesStep(), opts...)
}
}
// ByLocations orders the results by locations terms.
func ByLocations(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
// ByEntities orders the results by entities terms.
func ByEntities(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newLocationsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByItemsCount orders the results by items count.
func ByItemsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newItemsStep(), opts...)
}
}
// ByItems orders the results by items terms.
func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newItemsStep(), append([]sql.OrderTerm{term}, terms...)...)
sqlgraph.OrderByNeighborTerms(s, newEntitiesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
@@ -236,6 +222,20 @@ func ByNotifiers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
}
}
// ByEntityTypesCount orders the results by entity_types count.
func ByEntityTypesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newEntityTypesStep(), opts...)
}
}
// ByEntityTypes orders the results by entity_types terms.
func ByEntityTypes(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newEntityTypesStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByItemTemplatesCount orders the results by item_templates count.
func ByItemTemplatesCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
@@ -256,18 +256,11 @@ func newUsersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, UsersTable, UsersColumn),
)
}
func newLocationsStep() *sqlgraph.Step {
func newEntitiesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(LocationsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
)
}
func newItemsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ItemsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
sqlgraph.To(EntitiesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
}
func newLabelsStep() *sqlgraph.Step {
@@ -291,6 +284,13 @@ func newNotifiersStep() *sqlgraph.Step {
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
)
}
func newEntityTypesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(EntityTypesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn),
)
}
func newItemTemplatesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),

View File

@@ -309,44 +309,21 @@ func HasUsersWith(preds ...predicate.User) predicate.Group {
})
}
// HasLocations applies the HasEdge predicate on the "locations" edge.
func HasLocations() predicate.Group {
// HasEntities applies the HasEdge predicate on the "entities" edge.
func HasEntities() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, LocationsTable, LocationsColumn),
sqlgraph.Edge(sqlgraph.O2M, false, EntitiesTable, EntitiesColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasLocationsWith applies the HasEdge predicate on the "locations" edge with a given conditions (other predicates).
func HasLocationsWith(preds ...predicate.Location) predicate.Group {
// HasEntitiesWith applies the HasEdge predicate on the "entities" edge with a given conditions (other predicates).
func HasEntitiesWith(preds ...predicate.Entity) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newLocationsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasItems applies the HasEdge predicate on the "items" edge.
func HasItems() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
func HasItemsWith(preds ...predicate.Item) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newItemsStep()
step := newEntitiesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
@@ -424,6 +401,29 @@ func HasNotifiersWith(preds ...predicate.Notifier) predicate.Group {
})
}
// HasEntityTypes applies the HasEdge predicate on the "entity_types" edge.
func HasEntityTypes() predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, EntityTypesTable, EntityTypesColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasEntityTypesWith applies the HasEdge predicate on the "entity_types" edge with a given conditions (other predicates).
func HasEntityTypesWith(preds ...predicate.EntityType) predicate.Group {
return predicate.Group(func(s *sql.Selector) {
step := newEntityTypesStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasItemTemplates applies the HasEdge predicate on the "item_templates" edge.
func HasItemTemplates() predicate.Group {
return predicate.Group(func(s *sql.Selector) {

View File

@@ -11,12 +11,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"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/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
)
@@ -105,34 +105,19 @@ func (_c *GroupCreate) AddUsers(v ...*User) *GroupCreate {
return _c.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_c *GroupCreate) AddLocationIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *GroupCreate) AddEntityIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddEntityIDs(ids...)
return _c
}
// AddLocations adds the "locations" edges to the Location entity.
func (_c *GroupCreate) AddLocations(v ...*Location) *GroupCreate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *GroupCreate) AddEntities(v ...*Entity) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *GroupCreate) AddItemIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddItemIDs(ids...)
return _c
}
// AddItems adds the "items" edges to the Item entity.
func (_c *GroupCreate) AddItems(v ...*Item) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddItemIDs(ids...)
return _c.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -180,6 +165,21 @@ func (_c *GroupCreate) AddNotifiers(v ...*Notifier) *GroupCreate {
return _c.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_c *GroupCreate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddEntityTypeIDs(ids...)
return _c
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_c *GroupCreate) AddEntityTypes(v ...*EntityType) *GroupCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_c *GroupCreate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupCreate {
_c.mutation.AddItemTemplateIDs(ids...)
@@ -334,31 +334,15 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -414,6 +398,22 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
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 = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemTemplatesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -13,12 +13,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"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/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
@@ -32,11 +32,11 @@ type GroupQuery struct {
inters []Interceptor
predicates []predicate.Group
withUsers *UserQuery
withLocations *LocationQuery
withItems *ItemQuery
withEntities *EntityQuery
withLabels *LabelQuery
withInvitationTokens *GroupInvitationTokenQuery
withNotifiers *NotifierQuery
withEntityTypes *EntityTypeQuery
withItemTemplates *ItemTemplateQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -96,9 +96,9 @@ func (_q *GroupQuery) QueryUsers() *UserQuery {
return query
}
// QueryLocations chains the current query on the "locations" edge.
func (_q *GroupQuery) QueryLocations() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
// QueryEntities chains the current query on the "entities" edge.
func (_q *GroupQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -109,30 +109,8 @@ func (_q *GroupQuery) QueryLocations() *LocationQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.LocationsTable, group.LocationsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryItems chains the current query on the "items" edge.
func (_q *GroupQuery) QueryItems() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.ItemsTable, group.ItemsColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.EntitiesTable, group.EntitiesColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -206,6 +184,28 @@ func (_q *GroupQuery) QueryNotifiers() *NotifierQuery {
return query
}
// QueryEntityTypes chains the current query on the "entity_types" edge.
func (_q *GroupQuery) QueryEntityTypes() *EntityTypeQuery {
query := (&EntityTypeClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(group.Table, group.FieldID, selector),
sqlgraph.To(entitytype.Table, entitytype.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, group.EntityTypesTable, group.EntityTypesColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryItemTemplates chains the current query on the "item_templates" edge.
func (_q *GroupQuery) QueryItemTemplates() *ItemTemplateQuery {
query := (&ItemTemplateClient{config: _q.config}).Query()
@@ -421,11 +421,11 @@ func (_q *GroupQuery) Clone() *GroupQuery {
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Group{}, _q.predicates...),
withUsers: _q.withUsers.Clone(),
withLocations: _q.withLocations.Clone(),
withItems: _q.withItems.Clone(),
withEntities: _q.withEntities.Clone(),
withLabels: _q.withLabels.Clone(),
withInvitationTokens: _q.withInvitationTokens.Clone(),
withNotifiers: _q.withNotifiers.Clone(),
withEntityTypes: _q.withEntityTypes.Clone(),
withItemTemplates: _q.withItemTemplates.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
@@ -444,25 +444,14 @@ func (_q *GroupQuery) WithUsers(opts ...func(*UserQuery)) *GroupQuery {
return _q
}
// WithLocations tells the query-builder to eager-load the nodes that are connected to
// the "locations" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithLocations(opts ...func(*LocationQuery)) *GroupQuery {
query := (&LocationClient{config: _q.config}).Query()
// WithEntities tells the query-builder to eager-load the nodes that are connected to
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithEntities(opts ...func(*EntityQuery)) *GroupQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withLocations = query
return _q
}
// WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery {
query := (&ItemClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItems = query
_q.withEntities = query
return _q
}
@@ -499,6 +488,17 @@ func (_q *GroupQuery) WithNotifiers(opts ...func(*NotifierQuery)) *GroupQuery {
return _q
}
// WithEntityTypes tells the query-builder to eager-load the nodes that are connected to
// the "entity_types" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithEntityTypes(opts ...func(*EntityTypeQuery)) *GroupQuery {
query := (&EntityTypeClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withEntityTypes = query
return _q
}
// WithItemTemplates tells the query-builder to eager-load the nodes that are connected to
// the "item_templates" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithItemTemplates(opts ...func(*ItemTemplateQuery)) *GroupQuery {
@@ -590,11 +590,11 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
_spec = _q.querySpec()
loadedTypes = [7]bool{
_q.withUsers != nil,
_q.withLocations != nil,
_q.withItems != nil,
_q.withEntities != nil,
_q.withLabels != nil,
_q.withInvitationTokens != nil,
_q.withNotifiers != nil,
_q.withEntityTypes != nil,
_q.withItemTemplates != nil,
}
)
@@ -623,17 +623,10 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
if query := _q.withLocations; query != nil {
if err := _q.loadLocations(ctx, query, nodes,
func(n *Group) { n.Edges.Locations = []*Location{} },
func(n *Group, e *Location) { n.Edges.Locations = append(n.Edges.Locations, e) }); err != nil {
return nil, err
}
}
if query := _q.withItems; query != nil {
if err := _q.loadItems(ctx, query, nodes,
func(n *Group) { n.Edges.Items = []*Item{} },
func(n *Group, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
if query := _q.withEntities; query != nil {
if err := _q.loadEntities(ctx, query, nodes,
func(n *Group) { n.Edges.Entities = []*Entity{} },
func(n *Group, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
return nil, err
}
}
@@ -660,6 +653,13 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nil, err
}
}
if query := _q.withEntityTypes; query != nil {
if err := _q.loadEntityTypes(ctx, query, nodes,
func(n *Group) { n.Edges.EntityTypes = []*EntityType{} },
func(n *Group, e *EntityType) { n.Edges.EntityTypes = append(n.Edges.EntityTypes, e) }); err != nil {
return nil, err
}
}
if query := _q.withItemTemplates; query != nil {
if err := _q.loadItemTemplates(ctx, query, nodes,
func(n *Group) { n.Edges.ItemTemplates = []*ItemTemplate{} },
@@ -701,7 +701,7 @@ func (_q *GroupQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*
}
return nil
}
func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, nodes []*Group, init func(*Group), assign func(*Group, *Location)) error {
func (_q *GroupQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Group, init func(*Group), assign func(*Group, *Entity)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
@@ -712,52 +712,21 @@ func (_q *GroupQuery) loadLocations(ctx context.Context, query *LocationQuery, n
}
}
query.withFKs = true
query.Where(predicate.Location(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.LocationsColumn), fks...))
query.Where(predicate.Entity(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.EntitiesColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_locations
fk := n.group_entities
if fk == nil {
return fmt.Errorf(`foreign-key "group_locations" is nil for node %v`, n.ID)
return fmt.Errorf(`foreign-key "group_entities" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_locations" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *GroupQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Group, init func(*Group), assign func(*Group, *Item)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Item(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.ItemsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_items
if fk == nil {
return fmt.Errorf(`foreign-key "group_items" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_items" returned %v for node %v`, *fk, n.ID)
return fmt.Errorf(`unexpected referenced foreign-key "group_entities" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
@@ -855,6 +824,37 @@ func (_q *GroupQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, n
}
return nil
}
func (_q *GroupQuery) loadEntityTypes(ctx context.Context, query *EntityTypeQuery, nodes []*Group, init func(*Group), assign func(*Group, *EntityType)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.EntityType(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.EntityTypesColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.group_entity_types
if fk == nil {
return fmt.Errorf(`foreign-key "group_entity_types" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "group_entity_types" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *GroupQuery) loadItemTemplates(ctx context.Context, query *ItemTemplateQuery, nodes []*Group, init func(*Group), assign func(*Group, *ItemTemplate)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uuid.UUID]*Group)

View File

@@ -12,12 +12,12 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"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/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
@@ -85,34 +85,19 @@ func (_u *GroupUpdate) AddUsers(v ...*User) *GroupUpdate {
return _u.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdate) AddLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdate) AddEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdate) AddLocations(v ...*Location) *GroupUpdate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdate) AddEntities(v ...*Entity) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *GroupUpdate) AddItemIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *GroupUpdate) AddItems(v ...*Item) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -160,6 +145,21 @@ func (_u *GroupUpdate) AddNotifiers(v ...*Notifier) *GroupUpdate {
return _u.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_u *GroupUpdate) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddEntityTypeIDs(ids...)
return _u
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_u *GroupUpdate) AddEntityTypes(v ...*EntityType) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_u *GroupUpdate) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.AddItemTemplateIDs(ids...)
@@ -201,46 +201,25 @@ func (_u *GroupUpdate) RemoveUsers(v ...*User) *GroupUpdate {
return _u.RemoveUserIDs(ids...)
}
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdate) ClearLocations() *GroupUpdate {
_u.mutation.ClearLocations()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdate) ClearEntities() *GroupUpdate {
_u.mutation.ClearEntities()
return _u
}
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdate) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveLocationIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdate) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdate) RemoveLocations(v ...*Location) *GroupUpdate {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdate) RemoveEntities(v ...*Entity) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveLocationIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *GroupUpdate) ClearItems() *GroupUpdate {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *GroupUpdate) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *GroupUpdate) RemoveItems(v ...*Item) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -306,6 +285,27 @@ func (_u *GroupUpdate) RemoveNotifiers(v ...*Notifier) *GroupUpdate {
return _u.RemoveNotifierIDs(ids...)
}
// ClearEntityTypes clears all "entity_types" edges to the EntityType entity.
func (_u *GroupUpdate) ClearEntityTypes() *GroupUpdate {
_u.mutation.ClearEntityTypes()
return _u
}
// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs.
func (_u *GroupUpdate) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdate {
_u.mutation.RemoveEntityTypeIDs(ids...)
return _u
}
// RemoveEntityTypes removes "entity_types" edges to EntityType entities.
func (_u *GroupUpdate) RemoveEntityTypes(v ...*EntityType) *GroupUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityTypeIDs(ids...)
}
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
func (_u *GroupUpdate) ClearItemTemplates() *GroupUpdate {
_u.mutation.ClearItemTemplates()
@@ -439,28 +439,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.LocationsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -468,60 +468,15 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.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.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.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.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -664,6 +619,51 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
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.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
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.ItemTemplatesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
@@ -778,34 +778,19 @@ func (_u *GroupUpdateOne) AddUsers(v ...*User) *GroupUpdateOne {
return _u.AddUserIDs(ids...)
}
// AddLocationIDs adds the "locations" edge to the Location entity by IDs.
func (_u *GroupUpdateOne) AddLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddLocationIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *GroupUpdateOne) AddEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddLocations adds the "locations" edges to the Location entity.
func (_u *GroupUpdateOne) AddLocations(v ...*Location) *GroupUpdateOne {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) AddEntities(v ...*Entity) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddLocationIDs(ids...)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *GroupUpdateOne) AddItemIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddItemIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *GroupUpdateOne) AddItems(v ...*Item) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
@@ -853,6 +838,21 @@ func (_u *GroupUpdateOne) AddNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.AddNotifierIDs(ids...)
}
// AddEntityTypeIDs adds the "entity_types" edge to the EntityType entity by IDs.
func (_u *GroupUpdateOne) AddEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddEntityTypeIDs(ids...)
return _u
}
// AddEntityTypes adds the "entity_types" edges to the EntityType entity.
func (_u *GroupUpdateOne) AddEntityTypes(v ...*EntityType) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddEntityTypeIDs(ids...)
}
// AddItemTemplateIDs adds the "item_templates" edge to the ItemTemplate entity by IDs.
func (_u *GroupUpdateOne) AddItemTemplateIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.AddItemTemplateIDs(ids...)
@@ -894,46 +894,25 @@ func (_u *GroupUpdateOne) RemoveUsers(v ...*User) *GroupUpdateOne {
return _u.RemoveUserIDs(ids...)
}
// ClearLocations clears all "locations" edges to the Location entity.
func (_u *GroupUpdateOne) ClearLocations() *GroupUpdateOne {
_u.mutation.ClearLocations()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *GroupUpdateOne) ClearEntities() *GroupUpdateOne {
_u.mutation.ClearEntities()
return _u
}
// RemoveLocationIDs removes the "locations" edge to Location entities by IDs.
func (_u *GroupUpdateOne) RemoveLocationIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveLocationIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *GroupUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveLocations removes "locations" edges to Location entities.
func (_u *GroupUpdateOne) RemoveLocations(v ...*Location) *GroupUpdateOne {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *GroupUpdateOne) RemoveEntities(v ...*Entity) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveLocationIDs(ids...)
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *GroupUpdateOne) ClearItems() *GroupUpdateOne {
_u.mutation.ClearItems()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *GroupUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *GroupUpdateOne) RemoveItems(v ...*Item) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// ClearLabels clears all "labels" edges to the Label entity.
@@ -999,6 +978,27 @@ func (_u *GroupUpdateOne) RemoveNotifiers(v ...*Notifier) *GroupUpdateOne {
return _u.RemoveNotifierIDs(ids...)
}
// ClearEntityTypes clears all "entity_types" edges to the EntityType entity.
func (_u *GroupUpdateOne) ClearEntityTypes() *GroupUpdateOne {
_u.mutation.ClearEntityTypes()
return _u
}
// RemoveEntityTypeIDs removes the "entity_types" edge to EntityType entities by IDs.
func (_u *GroupUpdateOne) RemoveEntityTypeIDs(ids ...uuid.UUID) *GroupUpdateOne {
_u.mutation.RemoveEntityTypeIDs(ids...)
return _u
}
// RemoveEntityTypes removes "entity_types" edges to EntityType entities.
func (_u *GroupUpdateOne) RemoveEntityTypes(v ...*EntityType) *GroupUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveEntityTypeIDs(ids...)
}
// ClearItemTemplates clears all "item_templates" edges to the ItemTemplate entity.
func (_u *GroupUpdateOne) ClearItemTemplates() *GroupUpdateOne {
_u.mutation.ClearItemTemplates()
@@ -1162,28 +1162,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.LocationsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedLocationsIDs(); len(nodes) > 0 && !_u.mutation.LocationsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -1191,60 +1191,15 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.LocationsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.LocationsTable,
Columns: []string{group.LocationsColumn},
Table: group.EntitiesTable,
Columns: []string{group.EntitiesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.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.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.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.ItemsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.ItemsTable,
Columns: []string{group.ItemsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -1387,6 +1342,51 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(entitytype.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedEntityTypesIDs(); len(nodes) > 0 && !_u.mutation.EntityTypesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
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.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.EntityTypesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: group.EntityTypesTable,
Columns: []string{group.EntityTypesColumn},
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.ItemTemplatesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,

View File

@@ -16,6 +16,18 @@ func (_m *AuthTokens) GetID() uuid.UUID {
return _m.ID
}
func (_m *Entity) GetID() uuid.UUID {
return _m.ID
}
func (_m *EntityField) GetID() uuid.UUID {
return _m.ID
}
func (_m *EntityType) GetID() uuid.UUID {
return _m.ID
}
func (_m *Group) GetID() uuid.UUID {
return _m.ID
}
@@ -24,14 +36,6 @@ func (_m *GroupInvitationToken) GetID() uuid.UUID {
return _m.ID
}
func (_m *Item) GetID() uuid.UUID {
return _m.ID
}
func (_m *ItemField) GetID() uuid.UUID {
return _m.ID
}
func (_m *ItemTemplate) GetID() uuid.UUID {
return _m.ID
}
@@ -40,10 +44,6 @@ func (_m *Label) GetID() uuid.UUID {
return _m.ID
}
func (_m *Location) GetID() uuid.UUID {
return _m.ID
}
func (_m *MaintenanceEntry) GetID() uuid.UUID {
return _m.ID
}

View File

@@ -45,6 +45,42 @@ func (f AuthTokensFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthTokensMutation", m)
}
// The EntityFunc type is an adapter to allow the use of ordinary
// function as Entity mutator.
type EntityFunc func(context.Context, *ent.EntityMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityMutation", m)
}
// The EntityFieldFunc type is an adapter to allow the use of ordinary
// function as EntityField mutator.
type EntityFieldFunc func(context.Context, *ent.EntityFieldMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityFieldMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityFieldMutation", m)
}
// The EntityTypeFunc type is an adapter to allow the use of ordinary
// function as EntityType mutator.
type EntityTypeFunc func(context.Context, *ent.EntityTypeMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f EntityTypeFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.EntityTypeMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EntityTypeMutation", m)
}
// The GroupFunc type is an adapter to allow the use of ordinary
// function as Group mutator.
type GroupFunc func(context.Context, *ent.GroupMutation) (ent.Value, error)
@@ -69,30 +105,6 @@ func (f GroupInvitationTokenFunc) Mutate(ctx context.Context, m ent.Mutation) (e
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.GroupInvitationTokenMutation", m)
}
// The ItemFunc type is an adapter to allow the use of ordinary
// function as Item mutator.
type ItemFunc func(context.Context, *ent.ItemMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ItemMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemMutation", m)
}
// The ItemFieldFunc type is an adapter to allow the use of ordinary
// function as ItemField mutator.
type ItemFieldFunc func(context.Context, *ent.ItemFieldMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f ItemFieldFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.ItemFieldMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemFieldMutation", m)
}
// The ItemTemplateFunc type is an adapter to allow the use of ordinary
// function as ItemTemplate mutator.
type ItemTemplateFunc func(context.Context, *ent.ItemTemplateMutation) (ent.Value, error)
@@ -117,18 +129,6 @@ func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m)
}
// The LocationFunc type is an adapter to allow the use of ordinary
// function as Location mutator.
type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f LocationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.LocationMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LocationMutation", m)
}
// The MaintenanceEntryFunc type is an adapter to allow the use of ordinary
// function as MaintenanceEntry mutator.
type MaintenanceEntryFunc func(context.Context, *ent.MaintenanceEntryMutation) (ent.Value, error)

View File

@@ -11,9 +11,9 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
)
// ItemTemplate is the model entity for the ItemTemplate schema.
@@ -70,7 +70,7 @@ type ItemTemplateEdges struct {
// Fields holds the value of the fields edge.
Fields []*TemplateField `json:"fields,omitempty"`
// Location holds the value of the location edge.
Location *Location `json:"location,omitempty"`
Location *Entity `json:"location,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [3]bool
@@ -98,11 +98,11 @@ func (e ItemTemplateEdges) FieldsOrErr() ([]*TemplateField, error) {
// LocationOrErr returns the Location value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ItemTemplateEdges) LocationOrErr() (*Location, error) {
func (e ItemTemplateEdges) LocationOrErr() (*Entity, error) {
if e.Location != nil {
return e.Location, nil
} else if e.loadedTypes[2] {
return nil, &NotFoundError{label: location.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "location"}
}
@@ -291,7 +291,7 @@ func (_m *ItemTemplate) QueryFields() *TemplateFieldQuery {
}
// QueryLocation queries the "location" edge of the ItemTemplate entity.
func (_m *ItemTemplate) QueryLocation() *LocationQuery {
func (_m *ItemTemplate) QueryLocation() *EntityQuery {
return NewItemTemplateClient(_m.config).QueryLocation(_m)
}

View File

@@ -73,9 +73,9 @@ const (
FieldsColumn = "item_template_fields"
// LocationTable is the table that holds the location relation/edge.
LocationTable = "item_templates"
// LocationInverseTable is the table name for the Location entity.
// It exists in this package in order to avoid circular dependency with the "location" package.
LocationInverseTable = "locations"
// LocationInverseTable is the table name for the Entity entity.
// It exists in this package in order to avoid circular dependency with the "entity" package.
LocationInverseTable = "entities"
// LocationColumn is the table column denoting the location relation/edge.
LocationColumn = "item_template_location"
)

View File

@@ -964,7 +964,7 @@ func HasLocation() predicate.ItemTemplate {
}
// HasLocationWith applies the HasEdge predicate on the "location" edge with a given conditions (other predicates).
func HasLocationWith(preds ...predicate.Location) predicate.ItemTemplate {
func HasLocationWith(preds ...predicate.Entity) predicate.ItemTemplate {
return predicate.ItemTemplate(func(s *sql.Selector) {
step := newLocationStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {

View File

@@ -11,9 +11,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -286,13 +286,13 @@ func (_c *ItemTemplateCreate) AddFields(v ...*TemplateField) *ItemTemplateCreate
return _c.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_c *ItemTemplateCreate) SetLocationID(id uuid.UUID) *ItemTemplateCreate {
_c.mutation.SetLocationID(id)
return _c
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateCreate {
if id != nil {
_c = _c.SetLocationID(*id)
@@ -300,8 +300,8 @@ func (_c *ItemTemplateCreate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate
return _c
}
// SetLocation sets the "location" edge to the Location entity.
func (_c *ItemTemplateCreate) SetLocation(v *Location) *ItemTemplateCreate {
// SetLocation sets the "location" edge to the Entity entity.
func (_c *ItemTemplateCreate) SetLocation(v *Entity) *ItemTemplateCreate {
return _c.SetLocationID(v.ID)
}
@@ -594,7 +594,7 @@ func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec)
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -13,9 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -29,7 +29,7 @@ type ItemTemplateQuery struct {
predicates []predicate.ItemTemplate
withGroup *GroupQuery
withFields *TemplateFieldQuery
withLocation *LocationQuery
withLocation *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
@@ -112,8 +112,8 @@ func (_q *ItemTemplateQuery) QueryFields() *TemplateFieldQuery {
}
// QueryLocation chains the current query on the "location" edge.
func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
query := (&LocationClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) QueryLocation() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -124,7 +124,7 @@ func (_q *ItemTemplateQuery) QueryLocation() *LocationQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(itemtemplate.Table, itemtemplate.FieldID, selector),
sqlgraph.To(location.Table, location.FieldID),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, itemtemplate.LocationTable, itemtemplate.LocationColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
@@ -358,8 +358,8 @@ func (_q *ItemTemplateQuery) WithFields(opts ...func(*TemplateFieldQuery)) *Item
// WithLocation tells the query-builder to eager-load the nodes that are connected to
// the "location" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*LocationQuery)) *ItemTemplateQuery {
query := (&LocationClient{config: _q.config}).Query()
func (_q *ItemTemplateQuery) WithLocation(opts ...func(*EntityQuery)) *ItemTemplateQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
@@ -491,7 +491,7 @@ func (_q *ItemTemplateQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
}
if query := _q.withLocation; query != nil {
if err := _q.loadLocation(ctx, query, nodes, nil,
func(n *ItemTemplate, e *Location) { n.Edges.Location = e }); err != nil {
func(n *ItemTemplate, e *Entity) { n.Edges.Location = e }); err != nil {
return nil, err
}
}
@@ -561,7 +561,7 @@ func (_q *ItemTemplateQuery) loadFields(ctx context.Context, query *TemplateFiel
}
return nil
}
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Location)) error {
func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *EntityQuery, nodes []*ItemTemplate, init func(*ItemTemplate), assign func(*ItemTemplate, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*ItemTemplate)
for i := range nodes {
@@ -577,7 +577,7 @@ func (_q *ItemTemplateQuery) loadLocation(ctx context.Context, query *LocationQu
if len(ids) == 0 {
return nil
}
query.Where(location.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err

View File

@@ -13,9 +13,9 @@ import (
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
)
@@ -328,13 +328,13 @@ func (_u *ItemTemplateUpdate) AddFields(v ...*TemplateField) *ItemTemplateUpdate
return _u.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_u *ItemTemplateUpdate) SetLocationID(id uuid.UUID) *ItemTemplateUpdate {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdate {
if id != nil {
_u = _u.SetLocationID(*id)
@@ -342,8 +342,8 @@ func (_u *ItemTemplateUpdate) SetNillableLocationID(id *uuid.UUID) *ItemTemplate
return _u
}
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Location) *ItemTemplateUpdate {
// SetLocation sets the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdate) SetLocation(v *Entity) *ItemTemplateUpdate {
return _u.SetLocationID(v.ID)
}
@@ -379,7 +379,7 @@ func (_u *ItemTemplateUpdate) RemoveFields(v ...*TemplateField) *ItemTemplateUpd
return _u.RemoveFieldIDs(ids...)
}
// ClearLocation clears the "location" edge to the Location entity.
// ClearLocation clears the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdate) ClearLocation() *ItemTemplateUpdate {
_u.mutation.ClearLocation()
return _u
@@ -643,7 +643,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -656,7 +656,7 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -979,13 +979,13 @@ func (_u *ItemTemplateUpdateOne) AddFields(v ...*TemplateField) *ItemTemplateUpd
return _u.AddFieldIDs(ids...)
}
// SetLocationID sets the "location" edge to the Location entity by ID.
// SetLocationID sets the "location" edge to the Entity entity by ID.
func (_u *ItemTemplateUpdateOne) SetLocationID(id uuid.UUID) *ItemTemplateUpdateOne {
_u.mutation.SetLocationID(id)
return _u
}
// SetNillableLocationID sets the "location" edge to the Location entity by ID if the given value is not nil.
// SetNillableLocationID sets the "location" edge to the Entity entity by ID if the given value is not nil.
func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTemplateUpdateOne {
if id != nil {
_u = _u.SetLocationID(*id)
@@ -993,8 +993,8 @@ func (_u *ItemTemplateUpdateOne) SetNillableLocationID(id *uuid.UUID) *ItemTempl
return _u
}
// SetLocation sets the "location" edge to the Location entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Location) *ItemTemplateUpdateOne {
// SetLocation sets the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdateOne) SetLocation(v *Entity) *ItemTemplateUpdateOne {
return _u.SetLocationID(v.ID)
}
@@ -1030,7 +1030,7 @@ func (_u *ItemTemplateUpdateOne) RemoveFields(v ...*TemplateField) *ItemTemplate
return _u.RemoveFieldIDs(ids...)
}
// ClearLocation clears the "location" edge to the Location entity.
// ClearLocation clears the "location" edge to the Entity entity.
func (_u *ItemTemplateUpdateOne) ClearLocation() *ItemTemplateUpdateOne {
_u.mutation.ClearLocation()
return _u
@@ -1324,7 +1324,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -1337,7 +1337,7 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla
Columns: []string{itemtemplate.LocationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(location.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -40,8 +40,8 @@ type Label struct {
type LabelEdges struct {
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// Items holds the value of the items edge.
Items []*Item `json:"items,omitempty"`
// Entities holds the value of the entities edge.
Entities []*Entity `json:"entities,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
@@ -58,13 +58,13 @@ func (e LabelEdges) GroupOrErr() (*Group, error) {
return nil, &NotLoadedError{edge: "group"}
}
// ItemsOrErr returns the Items value or an error if the edge
// EntitiesOrErr returns the Entities value or an error if the edge
// was not loaded in eager-loading.
func (e LabelEdges) ItemsOrErr() ([]*Item, error) {
func (e LabelEdges) EntitiesOrErr() ([]*Entity, error) {
if e.loadedTypes[1] {
return e.Items, nil
return e.Entities, nil
}
return nil, &NotLoadedError{edge: "items"}
return nil, &NotLoadedError{edge: "entities"}
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -156,9 +156,9 @@ func (_m *Label) QueryGroup() *GroupQuery {
return NewLabelClient(_m.config).QueryGroup(_m)
}
// QueryItems queries the "items" edge of the Label entity.
func (_m *Label) QueryItems() *ItemQuery {
return NewLabelClient(_m.config).QueryItems(_m)
// QueryEntities queries the "entities" edge of the Label entity.
func (_m *Label) QueryEntities() *EntityQuery {
return NewLabelClient(_m.config).QueryEntities(_m)
}
// Update returns a builder for updating this Label.

View File

@@ -11,8 +11,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
)
@@ -110,19 +110,19 @@ func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate {
return _c.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_c *LabelCreate) AddEntityIDs(ids ...uuid.UUID) *LabelCreate {
_c.mutation.AddEntityIDs(ids...)
return _c
}
// AddItems adds the "items" edges to the Item entity.
func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_c *LabelCreate) AddEntities(v ...*Entity) *LabelCreate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddItemIDs(ids...)
return _c.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -275,15 +275,15 @@ func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
_node.group_labels = &nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -13,8 +13,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -22,13 +22,13 @@ import (
// LabelQuery is the builder for querying Label entities.
type LabelQuery struct {
config
ctx *QueryContext
order []label.OrderOption
inters []Interceptor
predicates []predicate.Label
withGroup *GroupQuery
withItems *ItemQuery
withFKs bool
ctx *QueryContext
order []label.OrderOption
inters []Interceptor
predicates []predicate.Label
withGroup *GroupQuery
withEntities *EntityQuery
withFKs bool
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -87,9 +87,9 @@ func (_q *LabelQuery) QueryGroup() *GroupQuery {
return query
}
// QueryItems chains the current query on the "items" edge.
func (_q *LabelQuery) QueryItems() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntities chains the current query on the "entities" edge.
func (_q *LabelQuery) QueryEntities() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -100,8 +100,8 @@ func (_q *LabelQuery) QueryItems() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(label.Table, label.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, label.EntitiesTable, label.EntitiesPrimaryKey...),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -296,13 +296,13 @@ func (_q *LabelQuery) Clone() *LabelQuery {
return nil
}
return &LabelQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]label.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Label{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withItems: _q.withItems.Clone(),
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]label.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Label{}, _q.predicates...),
withGroup: _q.withGroup.Clone(),
withEntities: _q.withEntities.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
@@ -320,14 +320,14 @@ func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
return _q
}
// WithItems tells the query-builder to eager-load the nodes that are connected to
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntities tells the query-builder to eager-load the nodes that are connected to
// the "entities" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *LabelQuery) WithEntities(opts ...func(*EntityQuery)) *LabelQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItems = query
_q.withEntities = query
return _q
}
@@ -412,7 +412,7 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withGroup != nil,
_q.withItems != nil,
_q.withEntities != nil,
}
)
if _q.withGroup != nil {
@@ -445,10 +445,10 @@ func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label,
return nil, err
}
}
if query := _q.withItems; query != nil {
if err := _q.loadItems(ctx, query, nodes,
func(n *Label) { n.Edges.Items = []*Item{} },
func(n *Label, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
if query := _q.withEntities; query != nil {
if err := _q.loadEntities(ctx, query, nodes,
func(n *Label) { n.Edges.Entities = []*Entity{} },
func(n *Label, e *Entity) { n.Edges.Entities = append(n.Edges.Entities, e) }); err != nil {
return nil, err
}
}
@@ -487,7 +487,7 @@ func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []
}
return nil
}
func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) error {
func (_q *LabelQuery) loadEntities(ctx context.Context, query *EntityQuery, nodes []*Label, init func(*Label), assign func(*Label, *Entity)) error {
edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uuid.UUID]*Label)
nids := make(map[uuid.UUID]map[*Label]struct{})
@@ -499,11 +499,11 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
}
}
query.Where(func(s *sql.Selector) {
joinT := sql.Table(label.ItemsTable)
s.Join(joinT).On(s.C(item.FieldID), joinT.C(label.ItemsPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(label.ItemsPrimaryKey[0]), edgeIDs...))
joinT := sql.Table(label.EntitiesTable)
s.Join(joinT).On(s.C(entity.FieldID), joinT.C(label.EntitiesPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(label.EntitiesPrimaryKey[0]), edgeIDs...))
columns := s.SelectedColumns()
s.Select(joinT.C(label.ItemsPrimaryKey[0]))
s.Select(joinT.C(label.EntitiesPrimaryKey[0]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
@@ -533,14 +533,14 @@ func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
}
})
})
neighbors, err := withInterceptors[[]*Item](ctx, query, qr, query.inters)
neighbors, err := withInterceptors[[]*Entity](ctx, query, qr, query.inters)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nids[n.ID]
if !ok {
return fmt.Errorf(`unexpected "items" node returned %v`, n.ID)
return fmt.Errorf(`unexpected "entities" node returned %v`, n.ID)
}
for kn := range nodes {
assign(kn, n)

View File

@@ -12,8 +12,8 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -102,19 +102,19 @@ func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate {
return _u.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdate) AddEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdate) AddEntities(v ...*Entity) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -128,25 +128,25 @@ func (_u *LabelUpdate) ClearGroup() *LabelUpdate {
return _u
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdate) ClearItems() *LabelUpdate {
_u.mutation.ClearItems()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdate) ClearEntities() *LabelUpdate {
_u.mutation.ClearEntities()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveItemIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdate) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdate {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdate) RemoveEntities(v ...*Entity) *LabelUpdate {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
@@ -267,28 +267,28 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -296,15 +296,15 @@ func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -403,19 +403,19 @@ func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne {
return _u.SetGroupID(v.ID)
}
// AddItemIDs adds the "items" edge to the Item entity by IDs.
func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddItemIDs(ids...)
// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (_u *LabelUpdateOne) AddEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.AddEntityIDs(ids...)
return _u
}
// AddItems adds the "items" edges to the Item entity.
func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne {
// AddEntities adds the "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) AddEntities(v ...*Entity) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddItemIDs(ids...)
return _u.AddEntityIDs(ids...)
}
// Mutation returns the LabelMutation object of the builder.
@@ -429,25 +429,25 @@ func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
return _u
}
// ClearItems clears all "items" edges to the Item entity.
func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne {
_u.mutation.ClearItems()
// ClearEntities clears all "entities" edges to the Entity entity.
func (_u *LabelUpdateOne) ClearEntities() *LabelUpdateOne {
_u.mutation.ClearEntities()
return _u
}
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveItemIDs(ids...)
// RemoveEntityIDs removes the "entities" edge to Entity entities by IDs.
func (_u *LabelUpdateOne) RemoveEntityIDs(ids ...uuid.UUID) *LabelUpdateOne {
_u.mutation.RemoveEntityIDs(ids...)
return _u
}
// RemoveItems removes "items" edges to Item entities.
func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne {
// RemoveEntities removes "entities" edges to Entity entities.
func (_u *LabelUpdateOne) RemoveEntities(v ...*Entity) *LabelUpdateOne {
ids := make([]uuid.UUID, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveItemIDs(ids...)
return _u.RemoveEntityIDs(ids...)
}
// Where appends a list predicates to the LabelUpdate builder.
@@ -598,28 +598,28 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ItemsCleared() {
if _u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedItemsIDs(); len(nodes) > 0 && !_u.mutation.ItemsCleared() {
if nodes := _u.mutation.RemovedEntitiesIDs(); len(nodes) > 0 && !_u.mutation.EntitiesCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -627,15 +627,15 @@ func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemsIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntitiesIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: label.ItemsTable,
Columns: label.ItemsPrimaryKey,
Table: label.EntitiesTable,
Columns: label.EntitiesPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -10,7 +10,7 @@ import (
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
)
@@ -23,8 +23,8 @@ type MaintenanceEntry struct {
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// ItemID holds the value of the "item_id" field.
ItemID uuid.UUID `json:"item_id,omitempty"`
// EntityID holds the value of the "entity_id" field.
EntityID uuid.UUID `json:"entity_id,omitempty"`
// Date holds the value of the "date" field.
Date time.Time `json:"date,omitempty"`
// ScheduledDate holds the value of the "scheduled_date" field.
@@ -43,22 +43,22 @@ type MaintenanceEntry struct {
// MaintenanceEntryEdges holds the relations/edges for other nodes in the graph.
type MaintenanceEntryEdges struct {
// Item holds the value of the item edge.
Item *Item `json:"item,omitempty"`
// Entity holds the value of the entity edge.
Entity *Entity `json:"entity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ItemOrErr returns the Item value or an error if the edge
// EntityOrErr returns the Entity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e MaintenanceEntryEdges) ItemOrErr() (*Item, error) {
if e.Item != nil {
return e.Item, nil
func (e MaintenanceEntryEdges) EntityOrErr() (*Entity, error) {
if e.Entity != nil {
return e.Entity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: item.Label}
return nil, &NotFoundError{label: entity.Label}
}
return nil, &NotLoadedError{edge: "item"}
return nil, &NotLoadedError{edge: "entity"}
}
// scanValues returns the types for scanning values from sql.Rows.
@@ -72,7 +72,7 @@ func (*MaintenanceEntry) scanValues(columns []string) ([]any, error) {
values[i] = new(sql.NullString)
case maintenanceentry.FieldCreatedAt, maintenanceentry.FieldUpdatedAt, maintenanceentry.FieldDate, maintenanceentry.FieldScheduledDate:
values[i] = new(sql.NullTime)
case maintenanceentry.FieldID, maintenanceentry.FieldItemID:
case maintenanceentry.FieldID, maintenanceentry.FieldEntityID:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
@@ -107,11 +107,11 @@ func (_m *MaintenanceEntry) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case maintenanceentry.FieldItemID:
case maintenanceentry.FieldEntityID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field item_id", values[i])
return fmt.Errorf("unexpected type %T for field entity_id", values[i])
} else if value != nil {
_m.ItemID = *value
_m.EntityID = *value
}
case maintenanceentry.FieldDate:
if value, ok := values[i].(*sql.NullTime); !ok {
@@ -156,9 +156,9 @@ func (_m *MaintenanceEntry) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryItem queries the "item" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryItem() *ItemQuery {
return NewMaintenanceEntryClient(_m.config).QueryItem(_m)
// QueryEntity queries the "entity" edge of the MaintenanceEntry entity.
func (_m *MaintenanceEntry) QueryEntity() *EntityQuery {
return NewMaintenanceEntryClient(_m.config).QueryEntity(_m)
}
// Update returns a builder for updating this MaintenanceEntry.
@@ -190,8 +190,8 @@ func (_m *MaintenanceEntry) String() string {
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("item_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ItemID))
builder.WriteString("entity_id=")
builder.WriteString(fmt.Sprintf("%v", _m.EntityID))
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(_m.Date.Format(time.ANSIC))

View File

@@ -11,7 +11,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
)
@@ -50,9 +50,9 @@ func (_c *MaintenanceEntryCreate) SetNillableUpdatedAt(v *time.Time) *Maintenanc
return _c
}
// SetItemID sets the "item_id" field.
func (_c *MaintenanceEntryCreate) SetItemID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_c *MaintenanceEntryCreate) SetEntityID(v uuid.UUID) *MaintenanceEntryCreate {
_c.mutation.SetEntityID(v)
return _c
}
@@ -132,9 +132,9 @@ func (_c *MaintenanceEntryCreate) SetNillableID(v *uuid.UUID) *MaintenanceEntryC
return _c
}
// SetItem sets the "item" edge to the Item entity.
func (_c *MaintenanceEntryCreate) SetItem(v *Item) *MaintenanceEntryCreate {
return _c.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_c *MaintenanceEntryCreate) SetEntity(v *Entity) *MaintenanceEntryCreate {
return _c.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -198,8 +198,8 @@ func (_c *MaintenanceEntryCreate) check() error {
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MaintenanceEntry.updated_at"`)}
}
if _, ok := _c.mutation.ItemID(); !ok {
return &ValidationError{Name: "item_id", err: errors.New(`ent: missing required field "MaintenanceEntry.item_id"`)}
if _, ok := _c.mutation.EntityID(); !ok {
return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MaintenanceEntry.entity_id"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "MaintenanceEntry.name"`)}
@@ -217,8 +217,8 @@ func (_c *MaintenanceEntryCreate) check() error {
if _, ok := _c.mutation.Cost(); !ok {
return &ValidationError{Name: "cost", err: errors.New(`ent: missing required field "MaintenanceEntry.cost"`)}
}
if len(_c.mutation.ItemIDs()) == 0 {
return &ValidationError{Name: "item", err: errors.New(`ent: missing required edge "MaintenanceEntry.item"`)}
if len(_c.mutation.EntityIDs()) == 0 {
return &ValidationError{Name: "entity", err: errors.New(`ent: missing required edge "MaintenanceEntry.entity"`)}
}
return nil
}
@@ -283,21 +283,21 @@ func (_c *MaintenanceEntryCreate) createSpec() (*MaintenanceEntry, *sqlgraph.Cre
_spec.SetField(maintenanceentry.FieldCost, field.TypeFloat64, value)
_node.Cost = value
}
if nodes := _c.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _c.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.ItemID = nodes[0]
_node.EntityID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -24,7 +24,7 @@ type MaintenanceEntryQuery struct {
order []maintenanceentry.OrderOption
inters []Interceptor
predicates []predicate.MaintenanceEntry
withItem *ItemQuery
withEntity *EntityQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -61,9 +61,9 @@ func (_q *MaintenanceEntryQuery) Order(o ...maintenanceentry.OrderOption) *Maint
return _q
}
// QueryItem chains the current query on the "item" edge.
func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery {
query := (&ItemClient{config: _q.config}).Query()
// QueryEntity chains the current query on the "entity" edge.
func (_q *MaintenanceEntryQuery) QueryEntity() *EntityQuery {
query := (&EntityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
@@ -74,8 +74,8 @@ func (_q *MaintenanceEntryQuery) QueryItem() *ItemQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(maintenanceentry.Table, maintenanceentry.FieldID, selector),
sqlgraph.To(item.Table, item.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.ItemTable, maintenanceentry.ItemColumn),
sqlgraph.To(entity.Table, entity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, maintenanceentry.EntityTable, maintenanceentry.EntityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
@@ -275,21 +275,21 @@ func (_q *MaintenanceEntryQuery) Clone() *MaintenanceEntryQuery {
order: append([]maintenanceentry.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.MaintenanceEntry{}, _q.predicates...),
withItem: _q.withItem.Clone(),
withEntity: _q.withEntity.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithItem tells the query-builder to eager-load the nodes that are connected to
// the "item" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *MaintenanceEntryQuery) WithItem(opts ...func(*ItemQuery)) *MaintenanceEntryQuery {
query := (&ItemClient{config: _q.config}).Query()
// WithEntity tells the query-builder to eager-load the nodes that are connected to
// the "entity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *MaintenanceEntryQuery) WithEntity(opts ...func(*EntityQuery)) *MaintenanceEntryQuery {
query := (&EntityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withItem = query
_q.withEntity = query
return _q
}
@@ -372,7 +372,7 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook)
nodes = []*MaintenanceEntry{}
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withItem != nil,
_q.withEntity != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
@@ -393,20 +393,20 @@ func (_q *MaintenanceEntryQuery) sqlAll(ctx context.Context, hooks ...queryHook)
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withItem; query != nil {
if err := _q.loadItem(ctx, query, nodes, nil,
func(n *MaintenanceEntry, e *Item) { n.Edges.Item = e }); err != nil {
if query := _q.withEntity; query != nil {
if err := _q.loadEntity(ctx, query, nodes, nil,
func(n *MaintenanceEntry, e *Entity) { n.Edges.Entity = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Item)) error {
func (_q *MaintenanceEntryQuery) loadEntity(ctx context.Context, query *EntityQuery, nodes []*MaintenanceEntry, init func(*MaintenanceEntry), assign func(*MaintenanceEntry, *Entity)) error {
ids := make([]uuid.UUID, 0, len(nodes))
nodeids := make(map[uuid.UUID][]*MaintenanceEntry)
for i := range nodes {
fk := nodes[i].ItemID
fk := nodes[i].EntityID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
@@ -415,7 +415,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery,
if len(ids) == 0 {
return nil
}
query.Where(item.IDIn(ids...))
query.Where(entity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
@@ -423,7 +423,7 @@ func (_q *MaintenanceEntryQuery) loadItem(ctx context.Context, query *ItemQuery,
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "item_id" returned %v`, n.ID)
return fmt.Errorf(`unexpected foreign-key "entity_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
@@ -457,8 +457,8 @@ func (_q *MaintenanceEntryQuery) querySpec() *sqlgraph.QuerySpec {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if _q.withItem != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldItemID)
if _q.withEntity != nil {
_spec.Node.AddColumnOnce(maintenanceentry.FieldEntityID)
}
}
if ps := _q.predicates; len(ps) > 0 {

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/entity"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
)
@@ -36,16 +36,16 @@ func (_u *MaintenanceEntryUpdate) SetUpdatedAt(v time.Time) *MaintenanceEntryUpd
return _u
}
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdate) SetItemID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdate) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdate {
_u.mutation.SetEntityID(v)
return _u
}
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdate {
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdate) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdate {
if v != nil {
_u.SetItemID(*v)
_u.SetEntityID(*v)
}
return _u
}
@@ -145,9 +145,9 @@ func (_u *MaintenanceEntryUpdate) AddCost(v float64) *MaintenanceEntryUpdate {
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) SetItem(v *Item) *MaintenanceEntryUpdate {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) SetEntity(v *Entity) *MaintenanceEntryUpdate {
return _u.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -155,9 +155,9 @@ func (_u *MaintenanceEntryUpdate) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdate) ClearItem() *MaintenanceEntryUpdate {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdate) ClearEntity() *MaintenanceEntryUpdate {
_u.mutation.ClearEntity()
return _u
}
@@ -209,8 +209,8 @@ func (_u *MaintenanceEntryUpdate) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
}
return nil
}
@@ -257,28 +257,28 @@ func (_u *MaintenanceEntryUpdate) sqlSave(ctx context.Context) (_node int, err e
if value, ok := _u.mutation.AddedCost(); ok {
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -312,16 +312,16 @@ func (_u *MaintenanceEntryUpdateOne) SetUpdatedAt(v time.Time) *MaintenanceEntry
return _u
}
// SetItemID sets the "item_id" field.
func (_u *MaintenanceEntryUpdateOne) SetItemID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetItemID(v)
// SetEntityID sets the "entity_id" field.
func (_u *MaintenanceEntryUpdateOne) SetEntityID(v uuid.UUID) *MaintenanceEntryUpdateOne {
_u.mutation.SetEntityID(v)
return _u
}
// SetNillableItemID sets the "item_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableItemID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
// SetNillableEntityID sets the "entity_id" field if the given value is not nil.
func (_u *MaintenanceEntryUpdateOne) SetNillableEntityID(v *uuid.UUID) *MaintenanceEntryUpdateOne {
if v != nil {
_u.SetItemID(*v)
_u.SetEntityID(*v)
}
return _u
}
@@ -421,9 +421,9 @@ func (_u *MaintenanceEntryUpdateOne) AddCost(v float64) *MaintenanceEntryUpdateO
return _u
}
// SetItem sets the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) SetItem(v *Item) *MaintenanceEntryUpdateOne {
return _u.SetItemID(v.ID)
// SetEntity sets the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) SetEntity(v *Entity) *MaintenanceEntryUpdateOne {
return _u.SetEntityID(v.ID)
}
// Mutation returns the MaintenanceEntryMutation object of the builder.
@@ -431,9 +431,9 @@ func (_u *MaintenanceEntryUpdateOne) Mutation() *MaintenanceEntryMutation {
return _u.mutation
}
// ClearItem clears the "item" edge to the Item entity.
func (_u *MaintenanceEntryUpdateOne) ClearItem() *MaintenanceEntryUpdateOne {
_u.mutation.ClearItem()
// ClearEntity clears the "entity" edge to the Entity entity.
func (_u *MaintenanceEntryUpdateOne) ClearEntity() *MaintenanceEntryUpdateOne {
_u.mutation.ClearEntity()
return _u
}
@@ -498,8 +498,8 @@ func (_u *MaintenanceEntryUpdateOne) check() error {
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "MaintenanceEntry.description": %w`, err)}
}
}
if _u.mutation.ItemCleared() && len(_u.mutation.ItemIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.item"`)
if _u.mutation.EntityCleared() && len(_u.mutation.EntityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "MaintenanceEntry.entity"`)
}
return nil
}
@@ -563,28 +563,28 @@ func (_u *MaintenanceEntryUpdateOne) sqlSave(ctx context.Context) (_node *Mainte
if value, ok := _u.mutation.AddedCost(); ok {
_spec.AddField(maintenanceentry.FieldCost, field.TypeFloat64, value)
}
if _u.mutation.ItemCleared() {
if _u.mutation.EntityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ItemIDs(); len(nodes) > 0 {
if nodes := _u.mutation.EntityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: maintenanceentry.ItemTable,
Columns: []string{maintenanceentry.ItemColumn},
Table: maintenanceentry.EntityTable,
Columns: []string{maintenanceentry.EntityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -19,7 +19,7 @@ var (
{Name: "path", Type: field.TypeString, Default: ""},
{Name: "mime_type", Type: field.TypeString, Default: "application/octet-stream"},
{Name: "attachment_thumbnail", Type: field.TypeUUID, Unique: true, Nullable: true},
{Name: "item_attachments", Type: field.TypeUUID, Nullable: true},
{Name: "entity_attachments", Type: field.TypeUUID, Nullable: true},
}
// AttachmentsTable holds the schema information for the "attachments" table.
AttachmentsTable = &schema.Table{
@@ -34,9 +34,9 @@ var (
OnDelete: schema.SetNull,
},
{
Symbol: "attachments_items_attachments",
Symbol: "attachments_entities_attachments",
Columns: []*schema.Column{AttachmentsColumns[9]},
RefColumns: []*schema.Column{ItemsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -91,6 +91,168 @@ var (
},
},
}
// EntitiesColumns holds the columns for the "entities" table.
EntitiesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "quantity", Type: field.TypeInt, Default: 1},
{Name: "insured", Type: field.TypeBool, Default: false},
{Name: "archived", Type: field.TypeBool, Default: false},
{Name: "asset_id", Type: field.TypeInt, Default: 0},
{Name: "sync_child_entities_locations", Type: field.TypeBool, Default: false},
{Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "lifetime_warranty", Type: field.TypeBool, Default: false},
{Name: "warranty_expires", Type: field.TypeTime, Nullable: true},
{Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "purchase_time", Type: field.TypeTime, Nullable: true},
{Name: "purchase_from", Type: field.TypeString, Nullable: true},
{Name: "purchase_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_time", Type: field.TypeTime, Nullable: true},
{Name: "sold_to", Type: field.TypeString, Nullable: true},
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "entity_parent", Type: field.TypeUUID, Nullable: true},
{Name: "entity_location", Type: field.TypeUUID, Nullable: true},
{Name: "entity_type_entities", Type: field.TypeUUID, Nullable: true},
{Name: "group_entities", Type: field.TypeUUID},
}
// EntitiesTable holds the schema information for the "entities" table.
EntitiesTable = &schema.Table{
Name: "entities",
Columns: EntitiesColumns,
PrimaryKey: []*schema.Column{EntitiesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entities_entities_parent",
Columns: []*schema.Column{EntitiesColumns[25]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_entities_location",
Columns: []*schema.Column{EntitiesColumns[26]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_entity_types_entities",
Columns: []*schema.Column{EntitiesColumns[27]},
RefColumns: []*schema.Column{EntityTypesColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "entities_groups_entities",
Columns: []*schema.Column{EntitiesColumns[28]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "entity_name",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[3]},
},
{
Name: "entity_manufacturer",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[14]},
},
{
Name: "entity_model_number",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[13]},
},
{
Name: "entity_serial_number",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[12]},
},
{
Name: "entity_archived",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[9]},
},
{
Name: "entity_asset_id",
Unique: false,
Columns: []*schema.Column{EntitiesColumns[10]},
},
},
}
// EntityFieldsColumns holds the columns for the "entity_fields" table.
EntityFieldsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}},
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
{Name: "number_value", Type: field.TypeInt, Nullable: true},
{Name: "boolean_value", Type: field.TypeBool, Default: false},
{Name: "time_value", Type: field.TypeTime},
{Name: "entity_fields", Type: field.TypeUUID, Nullable: true},
}
// EntityFieldsTable holds the schema information for the "entity_fields" table.
EntityFieldsTable = &schema.Table{
Name: "entity_fields",
Columns: EntityFieldsColumns,
PrimaryKey: []*schema.Column{EntityFieldsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entity_fields_entities_fields",
Columns: []*schema.Column{EntityFieldsColumns[10]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// EntityTypesColumns holds the columns for the "entity_types" table.
EntityTypesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "icon", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "color", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "is_location", Type: field.TypeBool, Default: false},
{Name: "group_entity_types", Type: field.TypeUUID},
}
// EntityTypesTable holds the schema information for the "entity_types" table.
EntityTypesTable = &schema.Table{
Name: "entity_types",
Columns: EntityTypesColumns,
PrimaryKey: []*schema.Column{EntityTypesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "entity_types_groups_entity_types",
Columns: []*schema.Column{EntityTypesColumns[8]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "entitytype_name",
Unique: false,
Columns: []*schema.Column{EntityTypesColumns[3]},
},
{
Name: "entitytype_is_location",
Unique: false,
Columns: []*schema.Column{EntityTypesColumns[7]},
},
},
}
// GroupsColumns holds the columns for the "groups" table.
GroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -129,123 +291,6 @@ var (
},
},
}
// ItemsColumns holds the columns for the "items" table.
ItemsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "import_ref", Type: field.TypeString, Nullable: true, Size: 100},
{Name: "notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "quantity", Type: field.TypeInt, Default: 1},
{Name: "insured", Type: field.TypeBool, Default: false},
{Name: "archived", Type: field.TypeBool, Default: false},
{Name: "asset_id", Type: field.TypeInt, Default: 0},
{Name: "sync_child_items_locations", Type: field.TypeBool, Default: false},
{Name: "serial_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "model_number", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "manufacturer", Type: field.TypeString, Nullable: true, Size: 255},
{Name: "lifetime_warranty", Type: field.TypeBool, Default: false},
{Name: "warranty_expires", Type: field.TypeTime, Nullable: true},
{Name: "warranty_details", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "purchase_time", Type: field.TypeTime, Nullable: true},
{Name: "purchase_from", Type: field.TypeString, Nullable: true},
{Name: "purchase_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_time", Type: field.TypeTime, Nullable: true},
{Name: "sold_to", Type: field.TypeString, Nullable: true},
{Name: "sold_price", Type: field.TypeFloat64, Default: 0},
{Name: "sold_notes", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "group_items", Type: field.TypeUUID},
{Name: "item_children", Type: field.TypeUUID, Nullable: true},
{Name: "location_items", Type: field.TypeUUID, Nullable: true},
}
// ItemsTable holds the schema information for the "items" table.
ItemsTable = &schema.Table{
Name: "items",
Columns: ItemsColumns,
PrimaryKey: []*schema.Column{ItemsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "items_groups_items",
Columns: []*schema.Column{ItemsColumns[25]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "items_items_children",
Columns: []*schema.Column{ItemsColumns[26]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "items_locations_items",
Columns: []*schema.Column{ItemsColumns[27]},
RefColumns: []*schema.Column{LocationsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "item_name",
Unique: false,
Columns: []*schema.Column{ItemsColumns[3]},
},
{
Name: "item_manufacturer",
Unique: false,
Columns: []*schema.Column{ItemsColumns[14]},
},
{
Name: "item_model_number",
Unique: false,
Columns: []*schema.Column{ItemsColumns[13]},
},
{
Name: "item_serial_number",
Unique: false,
Columns: []*schema.Column{ItemsColumns[12]},
},
{
Name: "item_archived",
Unique: false,
Columns: []*schema.Column{ItemsColumns[9]},
},
{
Name: "item_asset_id",
Unique: false,
Columns: []*schema.Column{ItemsColumns[10]},
},
},
}
// ItemFieldsColumns holds the columns for the "item_fields" table.
ItemFieldsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "type", Type: field.TypeEnum, Enums: []string{"text", "number", "boolean", "time"}},
{Name: "text_value", Type: field.TypeString, Nullable: true, Size: 500},
{Name: "number_value", Type: field.TypeInt, Nullable: true},
{Name: "boolean_value", Type: field.TypeBool, Default: false},
{Name: "time_value", Type: field.TypeTime},
{Name: "item_fields", Type: field.TypeUUID, Nullable: true},
}
// ItemFieldsTable holds the schema information for the "item_fields" table.
ItemFieldsTable = &schema.Table{
Name: "item_fields",
Columns: ItemFieldsColumns,
PrimaryKey: []*schema.Column{ItemFieldsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "item_fields_items_fields",
Columns: []*schema.Column{ItemFieldsColumns[10]},
RefColumns: []*schema.Column{ItemsColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// ItemTemplatesColumns holds the columns for the "item_templates" table.
ItemTemplatesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -282,9 +327,9 @@ var (
OnDelete: schema.Cascade,
},
{
Symbol: "item_templates_locations_location",
Symbol: "item_templates_entities_location",
Columns: []*schema.Column{ItemTemplatesColumns[19]},
RefColumns: []*schema.Column{LocationsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.SetNull,
},
},
@@ -320,36 +365,6 @@ var (
},
},
}
// LocationsColumns holds the columns for the "locations" table.
LocationsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
{Name: "group_locations", Type: field.TypeUUID},
{Name: "location_children", Type: field.TypeUUID, Nullable: true},
}
// LocationsTable holds the schema information for the "locations" table.
LocationsTable = &schema.Table{
Name: "locations",
Columns: LocationsColumns,
PrimaryKey: []*schema.Column{LocationsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "locations_groups_locations",
Columns: []*schema.Column{LocationsColumns[5]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "locations_locations_children",
Columns: []*schema.Column{LocationsColumns[6]},
RefColumns: []*schema.Column{LocationsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// MaintenanceEntriesColumns holds the columns for the "maintenance_entries" table.
MaintenanceEntriesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
@@ -360,7 +375,7 @@ var (
{Name: "name", Type: field.TypeString, Size: 255},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 2500},
{Name: "cost", Type: field.TypeFloat64, Default: 0},
{Name: "item_id", Type: field.TypeUUID},
{Name: "entity_id", Type: field.TypeUUID},
}
// MaintenanceEntriesTable holds the schema information for the "maintenance_entries" table.
MaintenanceEntriesTable = &schema.Table{
@@ -369,9 +384,9 @@ var (
PrimaryKey: []*schema.Column{MaintenanceEntriesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "maintenance_entries_items_maintenance_entries",
Symbol: "maintenance_entries_entities_maintenance_entries",
Columns: []*schema.Column{MaintenanceEntriesColumns[8]},
RefColumns: []*schema.Column{ItemsColumns[0]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -491,27 +506,27 @@ var (
},
},
}
// LabelItemsColumns holds the columns for the "label_items" table.
LabelItemsColumns = []*schema.Column{
// LabelEntitiesColumns holds the columns for the "label_entities" table.
LabelEntitiesColumns = []*schema.Column{
{Name: "label_id", Type: field.TypeUUID},
{Name: "item_id", Type: field.TypeUUID},
{Name: "entity_id", Type: field.TypeUUID},
}
// LabelItemsTable holds the schema information for the "label_items" table.
LabelItemsTable = &schema.Table{
Name: "label_items",
Columns: LabelItemsColumns,
PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]},
// LabelEntitiesTable holds the schema information for the "label_entities" table.
LabelEntitiesTable = &schema.Table{
Name: "label_entities",
Columns: LabelEntitiesColumns,
PrimaryKey: []*schema.Column{LabelEntitiesColumns[0], LabelEntitiesColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "label_items_label_id",
Columns: []*schema.Column{LabelItemsColumns[0]},
Symbol: "label_entities_label_id",
Columns: []*schema.Column{LabelEntitiesColumns[0]},
RefColumns: []*schema.Column{LabelsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "label_items_item_id",
Columns: []*schema.Column{LabelItemsColumns[1]},
RefColumns: []*schema.Column{ItemsColumns[0]},
Symbol: "label_entities_entity_id",
Columns: []*schema.Column{LabelEntitiesColumns[1]},
RefColumns: []*schema.Column{EntitiesColumns[0]},
OnDelete: schema.Cascade,
},
},
@@ -521,41 +536,41 @@ var (
AttachmentsTable,
AuthRolesTable,
AuthTokensTable,
EntitiesTable,
EntityFieldsTable,
EntityTypesTable,
GroupsTable,
GroupInvitationTokensTable,
ItemsTable,
ItemFieldsTable,
ItemTemplatesTable,
LabelsTable,
LocationsTable,
MaintenanceEntriesTable,
NotifiersTable,
TemplateFieldsTable,
UsersTable,
LabelItemsTable,
LabelEntitiesTable,
}
)
func init() {
AttachmentsTable.ForeignKeys[0].RefTable = AttachmentsTable
AttachmentsTable.ForeignKeys[1].RefTable = ItemsTable
AttachmentsTable.ForeignKeys[1].RefTable = EntitiesTable
AuthRolesTable.ForeignKeys[0].RefTable = AuthTokensTable
AuthTokensTable.ForeignKeys[0].RefTable = UsersTable
EntitiesTable.ForeignKeys[0].RefTable = EntitiesTable
EntitiesTable.ForeignKeys[1].RefTable = EntitiesTable
EntitiesTable.ForeignKeys[2].RefTable = EntityTypesTable
EntitiesTable.ForeignKeys[3].RefTable = GroupsTable
EntityFieldsTable.ForeignKeys[0].RefTable = EntitiesTable
EntityTypesTable.ForeignKeys[0].RefTable = GroupsTable
GroupInvitationTokensTable.ForeignKeys[0].RefTable = GroupsTable
ItemsTable.ForeignKeys[0].RefTable = GroupsTable
ItemsTable.ForeignKeys[1].RefTable = ItemsTable
ItemsTable.ForeignKeys[2].RefTable = LocationsTable
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable
ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
ItemTemplatesTable.ForeignKeys[1].RefTable = EntitiesTable
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
MaintenanceEntriesTable.ForeignKeys[0].RefTable = EntitiesTable
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
UsersTable.ForeignKeys[0].RefTable = GroupsTable
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
LabelEntitiesTable.ForeignKeys[0].RefTable = LabelsTable
LabelEntitiesTable.ForeignKeys[1].RefTable = EntitiesTable
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,27 +15,27 @@ type AuthRoles func(*sql.Selector)
// AuthTokens is the predicate function for authtokens builders.
type AuthTokens func(*sql.Selector)
// Entity is the predicate function for entity builders.
type Entity func(*sql.Selector)
// EntityField is the predicate function for entityfield builders.
type EntityField func(*sql.Selector)
// EntityType is the predicate function for entitytype builders.
type EntityType func(*sql.Selector)
// Group is the predicate function for group builders.
type Group func(*sql.Selector)
// GroupInvitationToken is the predicate function for groupinvitationtoken builders.
type GroupInvitationToken func(*sql.Selector)
// Item is the predicate function for item builders.
type Item func(*sql.Selector)
// ItemField is the predicate function for itemfield builders.
type ItemField func(*sql.Selector)
// ItemTemplate is the predicate function for itemtemplate builders.
type ItemTemplate func(*sql.Selector)
// Label is the predicate function for label builders.
type Label func(*sql.Selector)
// Location is the predicate function for location builders.
type Location func(*sql.Selector)
// MaintenanceEntry is the predicate function for maintenanceentry builders.
type MaintenanceEntry func(*sql.Selector)

View File

@@ -8,13 +8,13 @@ import (
"github.com/google/uuid"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/attachment"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/authtokens"
"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/groupinvitationtoken"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
@@ -86,6 +86,219 @@ func init() {
authtokensDescID := authtokensMixinFields0[0].Descriptor()
// authtokens.DefaultID holds the default value on creation for the id field.
authtokens.DefaultID = authtokensDescID.Default.(func() uuid.UUID)
entityMixin := schema.Entity{}.Mixin()
entityMixinFields0 := entityMixin[0].Fields()
_ = entityMixinFields0
entityMixinFields1 := entityMixin[1].Fields()
_ = entityMixinFields1
entityFields := schema.Entity{}.Fields()
_ = entityFields
// entityDescCreatedAt is the schema descriptor for created_at field.
entityDescCreatedAt := entityMixinFields0[1].Descriptor()
// entity.DefaultCreatedAt holds the default value on creation for the created_at field.
entity.DefaultCreatedAt = entityDescCreatedAt.Default.(func() time.Time)
// entityDescUpdatedAt is the schema descriptor for updated_at field.
entityDescUpdatedAt := entityMixinFields0[2].Descriptor()
// entity.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entity.DefaultUpdatedAt = entityDescUpdatedAt.Default.(func() time.Time)
// entity.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entity.UpdateDefaultUpdatedAt = entityDescUpdatedAt.UpdateDefault.(func() time.Time)
// entityDescName is the schema descriptor for name field.
entityDescName := entityMixinFields1[0].Descriptor()
// entity.NameValidator is a validator for the "name" field. It is called by the builders before save.
entity.NameValidator = func() func(string) error {
validators := entityDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entityDescDescription is the schema descriptor for description field.
entityDescDescription := entityMixinFields1[1].Descriptor()
// entity.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entity.DescriptionValidator = entityDescDescription.Validators[0].(func(string) error)
// entityDescImportRef is the schema descriptor for import_ref field.
entityDescImportRef := entityFields[0].Descriptor()
// entity.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
entity.ImportRefValidator = entityDescImportRef.Validators[0].(func(string) error)
// entityDescNotes is the schema descriptor for notes field.
entityDescNotes := entityFields[1].Descriptor()
// entity.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
entity.NotesValidator = entityDescNotes.Validators[0].(func(string) error)
// entityDescQuantity is the schema descriptor for quantity field.
entityDescQuantity := entityFields[2].Descriptor()
// entity.DefaultQuantity holds the default value on creation for the quantity field.
entity.DefaultQuantity = entityDescQuantity.Default.(int)
// entityDescInsured is the schema descriptor for insured field.
entityDescInsured := entityFields[3].Descriptor()
// entity.DefaultInsured holds the default value on creation for the insured field.
entity.DefaultInsured = entityDescInsured.Default.(bool)
// entityDescArchived is the schema descriptor for archived field.
entityDescArchived := entityFields[4].Descriptor()
// entity.DefaultArchived holds the default value on creation for the archived field.
entity.DefaultArchived = entityDescArchived.Default.(bool)
// entityDescAssetID is the schema descriptor for asset_id field.
entityDescAssetID := entityFields[5].Descriptor()
// entity.DefaultAssetID holds the default value on creation for the asset_id field.
entity.DefaultAssetID = entityDescAssetID.Default.(int)
// entityDescSyncChildEntitiesLocations is the schema descriptor for sync_child_entities_locations field.
entityDescSyncChildEntitiesLocations := entityFields[6].Descriptor()
// entity.DefaultSyncChildEntitiesLocations holds the default value on creation for the sync_child_entities_locations field.
entity.DefaultSyncChildEntitiesLocations = entityDescSyncChildEntitiesLocations.Default.(bool)
// entityDescSerialNumber is the schema descriptor for serial_number field.
entityDescSerialNumber := entityFields[7].Descriptor()
// entity.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
entity.SerialNumberValidator = entityDescSerialNumber.Validators[0].(func(string) error)
// entityDescModelNumber is the schema descriptor for model_number field.
entityDescModelNumber := entityFields[8].Descriptor()
// entity.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
entity.ModelNumberValidator = entityDescModelNumber.Validators[0].(func(string) error)
// entityDescManufacturer is the schema descriptor for manufacturer field.
entityDescManufacturer := entityFields[9].Descriptor()
// entity.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
entity.ManufacturerValidator = entityDescManufacturer.Validators[0].(func(string) error)
// entityDescLifetimeWarranty is the schema descriptor for lifetime_warranty field.
entityDescLifetimeWarranty := entityFields[10].Descriptor()
// entity.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field.
entity.DefaultLifetimeWarranty = entityDescLifetimeWarranty.Default.(bool)
// entityDescWarrantyDetails is the schema descriptor for warranty_details field.
entityDescWarrantyDetails := entityFields[12].Descriptor()
// entity.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
entity.WarrantyDetailsValidator = entityDescWarrantyDetails.Validators[0].(func(string) error)
// entityDescPurchasePrice is the schema descriptor for purchase_price field.
entityDescPurchasePrice := entityFields[15].Descriptor()
// entity.DefaultPurchasePrice holds the default value on creation for the purchase_price field.
entity.DefaultPurchasePrice = entityDescPurchasePrice.Default.(float64)
// entityDescSoldPrice is the schema descriptor for sold_price field.
entityDescSoldPrice := entityFields[18].Descriptor()
// entity.DefaultSoldPrice holds the default value on creation for the sold_price field.
entity.DefaultSoldPrice = entityDescSoldPrice.Default.(float64)
// entityDescSoldNotes is the schema descriptor for sold_notes field.
entityDescSoldNotes := entityFields[19].Descriptor()
// entity.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
entity.SoldNotesValidator = entityDescSoldNotes.Validators[0].(func(string) error)
// entityDescID is the schema descriptor for id field.
entityDescID := entityMixinFields0[0].Descriptor()
// entity.DefaultID holds the default value on creation for the id field.
entity.DefaultID = entityDescID.Default.(func() uuid.UUID)
entityfieldMixin := schema.EntityField{}.Mixin()
entityfieldMixinFields0 := entityfieldMixin[0].Fields()
_ = entityfieldMixinFields0
entityfieldMixinFields1 := entityfieldMixin[1].Fields()
_ = entityfieldMixinFields1
entityfieldFields := schema.EntityField{}.Fields()
_ = entityfieldFields
// entityfieldDescCreatedAt is the schema descriptor for created_at field.
entityfieldDescCreatedAt := entityfieldMixinFields0[1].Descriptor()
// entityfield.DefaultCreatedAt holds the default value on creation for the created_at field.
entityfield.DefaultCreatedAt = entityfieldDescCreatedAt.Default.(func() time.Time)
// entityfieldDescUpdatedAt is the schema descriptor for updated_at field.
entityfieldDescUpdatedAt := entityfieldMixinFields0[2].Descriptor()
// entityfield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entityfield.DefaultUpdatedAt = entityfieldDescUpdatedAt.Default.(func() time.Time)
// entityfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entityfield.UpdateDefaultUpdatedAt = entityfieldDescUpdatedAt.UpdateDefault.(func() time.Time)
// entityfieldDescName is the schema descriptor for name field.
entityfieldDescName := entityfieldMixinFields1[0].Descriptor()
// entityfield.NameValidator is a validator for the "name" field. It is called by the builders before save.
entityfield.NameValidator = func() func(string) error {
validators := entityfieldDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entityfieldDescDescription is the schema descriptor for description field.
entityfieldDescDescription := entityfieldMixinFields1[1].Descriptor()
// entityfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entityfield.DescriptionValidator = entityfieldDescDescription.Validators[0].(func(string) error)
// entityfieldDescTextValue is the schema descriptor for text_value field.
entityfieldDescTextValue := entityfieldFields[1].Descriptor()
// entityfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
entityfield.TextValueValidator = entityfieldDescTextValue.Validators[0].(func(string) error)
// entityfieldDescBooleanValue is the schema descriptor for boolean_value field.
entityfieldDescBooleanValue := entityfieldFields[3].Descriptor()
// entityfield.DefaultBooleanValue holds the default value on creation for the boolean_value field.
entityfield.DefaultBooleanValue = entityfieldDescBooleanValue.Default.(bool)
// entityfieldDescTimeValue is the schema descriptor for time_value field.
entityfieldDescTimeValue := entityfieldFields[4].Descriptor()
// entityfield.DefaultTimeValue holds the default value on creation for the time_value field.
entityfield.DefaultTimeValue = entityfieldDescTimeValue.Default.(func() time.Time)
// entityfieldDescID is the schema descriptor for id field.
entityfieldDescID := entityfieldMixinFields0[0].Descriptor()
// entityfield.DefaultID holds the default value on creation for the id field.
entityfield.DefaultID = entityfieldDescID.Default.(func() uuid.UUID)
entitytypeMixin := schema.EntityType{}.Mixin()
entitytypeMixinFields0 := entitytypeMixin[0].Fields()
_ = entitytypeMixinFields0
entitytypeMixinFields1 := entitytypeMixin[1].Fields()
_ = entitytypeMixinFields1
entitytypeFields := schema.EntityType{}.Fields()
_ = entitytypeFields
// entitytypeDescCreatedAt is the schema descriptor for created_at field.
entitytypeDescCreatedAt := entitytypeMixinFields0[1].Descriptor()
// entitytype.DefaultCreatedAt holds the default value on creation for the created_at field.
entitytype.DefaultCreatedAt = entitytypeDescCreatedAt.Default.(func() time.Time)
// entitytypeDescUpdatedAt is the schema descriptor for updated_at field.
entitytypeDescUpdatedAt := entitytypeMixinFields0[2].Descriptor()
// entitytype.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entitytype.DefaultUpdatedAt = entitytypeDescUpdatedAt.Default.(func() time.Time)
// entitytype.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entitytype.UpdateDefaultUpdatedAt = entitytypeDescUpdatedAt.UpdateDefault.(func() time.Time)
// entitytypeDescName is the schema descriptor for name field.
entitytypeDescName := entitytypeMixinFields1[0].Descriptor()
// entitytype.NameValidator is a validator for the "name" field. It is called by the builders before save.
entitytype.NameValidator = func() func(string) error {
validators := entitytypeDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// entitytypeDescDescription is the schema descriptor for description field.
entitytypeDescDescription := entitytypeMixinFields1[1].Descriptor()
// entitytype.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
entitytype.DescriptionValidator = entitytypeDescDescription.Validators[0].(func(string) error)
// entitytypeDescIcon is the schema descriptor for icon field.
entitytypeDescIcon := entitytypeFields[0].Descriptor()
// entitytype.IconValidator is a validator for the "icon" field. It is called by the builders before save.
entitytype.IconValidator = entitytypeDescIcon.Validators[0].(func(string) error)
// entitytypeDescColor is the schema descriptor for color field.
entitytypeDescColor := entitytypeFields[1].Descriptor()
// entitytype.ColorValidator is a validator for the "color" field. It is called by the builders before save.
entitytype.ColorValidator = entitytypeDescColor.Validators[0].(func(string) error)
// entitytypeDescIsLocation is the schema descriptor for is_location field.
entitytypeDescIsLocation := entitytypeFields[2].Descriptor()
// entitytype.DefaultIsLocation holds the default value on creation for the is_location field.
entitytype.DefaultIsLocation = entitytypeDescIsLocation.Default.(bool)
// entitytypeDescID is the schema descriptor for id field.
entitytypeDescID := entitytypeMixinFields0[0].Descriptor()
// entitytype.DefaultID holds the default value on creation for the id field.
entitytype.DefaultID = entitytypeDescID.Default.(func() uuid.UUID)
groupMixin := schema.Group{}.Mixin()
groupMixinFields0 := groupMixin[0].Fields()
_ = groupMixinFields0
@@ -154,164 +367,6 @@ func init() {
groupinvitationtokenDescID := groupinvitationtokenMixinFields0[0].Descriptor()
// groupinvitationtoken.DefaultID holds the default value on creation for the id field.
groupinvitationtoken.DefaultID = groupinvitationtokenDescID.Default.(func() uuid.UUID)
itemMixin := schema.Item{}.Mixin()
itemMixinFields0 := itemMixin[0].Fields()
_ = itemMixinFields0
itemMixinFields1 := itemMixin[1].Fields()
_ = itemMixinFields1
itemFields := schema.Item{}.Fields()
_ = itemFields
// itemDescCreatedAt is the schema descriptor for created_at field.
itemDescCreatedAt := itemMixinFields0[1].Descriptor()
// item.DefaultCreatedAt holds the default value on creation for the created_at field.
item.DefaultCreatedAt = itemDescCreatedAt.Default.(func() time.Time)
// itemDescUpdatedAt is the schema descriptor for updated_at field.
itemDescUpdatedAt := itemMixinFields0[2].Descriptor()
// item.DefaultUpdatedAt holds the default value on creation for the updated_at field.
item.DefaultUpdatedAt = itemDescUpdatedAt.Default.(func() time.Time)
// item.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
item.UpdateDefaultUpdatedAt = itemDescUpdatedAt.UpdateDefault.(func() time.Time)
// itemDescName is the schema descriptor for name field.
itemDescName := itemMixinFields1[0].Descriptor()
// item.NameValidator is a validator for the "name" field. It is called by the builders before save.
item.NameValidator = func() func(string) error {
validators := itemDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// itemDescDescription is the schema descriptor for description field.
itemDescDescription := itemMixinFields1[1].Descriptor()
// item.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
item.DescriptionValidator = itemDescDescription.Validators[0].(func(string) error)
// itemDescImportRef is the schema descriptor for import_ref field.
itemDescImportRef := itemFields[0].Descriptor()
// item.ImportRefValidator is a validator for the "import_ref" field. It is called by the builders before save.
item.ImportRefValidator = itemDescImportRef.Validators[0].(func(string) error)
// itemDescNotes is the schema descriptor for notes field.
itemDescNotes := itemFields[1].Descriptor()
// item.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
item.NotesValidator = itemDescNotes.Validators[0].(func(string) error)
// itemDescQuantity is the schema descriptor for quantity field.
itemDescQuantity := itemFields[2].Descriptor()
// item.DefaultQuantity holds the default value on creation for the quantity field.
item.DefaultQuantity = itemDescQuantity.Default.(int)
// itemDescInsured is the schema descriptor for insured field.
itemDescInsured := itemFields[3].Descriptor()
// item.DefaultInsured holds the default value on creation for the insured field.
item.DefaultInsured = itemDescInsured.Default.(bool)
// itemDescArchived is the schema descriptor for archived field.
itemDescArchived := itemFields[4].Descriptor()
// item.DefaultArchived holds the default value on creation for the archived field.
item.DefaultArchived = itemDescArchived.Default.(bool)
// itemDescAssetID is the schema descriptor for asset_id field.
itemDescAssetID := itemFields[5].Descriptor()
// item.DefaultAssetID holds the default value on creation for the asset_id field.
item.DefaultAssetID = itemDescAssetID.Default.(int)
// itemDescSyncChildItemsLocations is the schema descriptor for sync_child_items_locations field.
itemDescSyncChildItemsLocations := itemFields[6].Descriptor()
// item.DefaultSyncChildItemsLocations holds the default value on creation for the sync_child_items_locations field.
item.DefaultSyncChildItemsLocations = itemDescSyncChildItemsLocations.Default.(bool)
// itemDescSerialNumber is the schema descriptor for serial_number field.
itemDescSerialNumber := itemFields[7].Descriptor()
// item.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
item.SerialNumberValidator = itemDescSerialNumber.Validators[0].(func(string) error)
// itemDescModelNumber is the schema descriptor for model_number field.
itemDescModelNumber := itemFields[8].Descriptor()
// item.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
item.ModelNumberValidator = itemDescModelNumber.Validators[0].(func(string) error)
// itemDescManufacturer is the schema descriptor for manufacturer field.
itemDescManufacturer := itemFields[9].Descriptor()
// item.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
item.ManufacturerValidator = itemDescManufacturer.Validators[0].(func(string) error)
// itemDescLifetimeWarranty is the schema descriptor for lifetime_warranty field.
itemDescLifetimeWarranty := itemFields[10].Descriptor()
// item.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field.
item.DefaultLifetimeWarranty = itemDescLifetimeWarranty.Default.(bool)
// itemDescWarrantyDetails is the schema descriptor for warranty_details field.
itemDescWarrantyDetails := itemFields[12].Descriptor()
// item.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
item.WarrantyDetailsValidator = itemDescWarrantyDetails.Validators[0].(func(string) error)
// itemDescPurchasePrice is the schema descriptor for purchase_price field.
itemDescPurchasePrice := itemFields[15].Descriptor()
// item.DefaultPurchasePrice holds the default value on creation for the purchase_price field.
item.DefaultPurchasePrice = itemDescPurchasePrice.Default.(float64)
// itemDescSoldPrice is the schema descriptor for sold_price field.
itemDescSoldPrice := itemFields[18].Descriptor()
// item.DefaultSoldPrice holds the default value on creation for the sold_price field.
item.DefaultSoldPrice = itemDescSoldPrice.Default.(float64)
// itemDescSoldNotes is the schema descriptor for sold_notes field.
itemDescSoldNotes := itemFields[19].Descriptor()
// item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error)
// itemDescID is the schema descriptor for id field.
itemDescID := itemMixinFields0[0].Descriptor()
// item.DefaultID holds the default value on creation for the id field.
item.DefaultID = itemDescID.Default.(func() uuid.UUID)
itemfieldMixin := schema.ItemField{}.Mixin()
itemfieldMixinFields0 := itemfieldMixin[0].Fields()
_ = itemfieldMixinFields0
itemfieldMixinFields1 := itemfieldMixin[1].Fields()
_ = itemfieldMixinFields1
itemfieldFields := schema.ItemField{}.Fields()
_ = itemfieldFields
// itemfieldDescCreatedAt is the schema descriptor for created_at field.
itemfieldDescCreatedAt := itemfieldMixinFields0[1].Descriptor()
// itemfield.DefaultCreatedAt holds the default value on creation for the created_at field.
itemfield.DefaultCreatedAt = itemfieldDescCreatedAt.Default.(func() time.Time)
// itemfieldDescUpdatedAt is the schema descriptor for updated_at field.
itemfieldDescUpdatedAt := itemfieldMixinFields0[2].Descriptor()
// itemfield.DefaultUpdatedAt holds the default value on creation for the updated_at field.
itemfield.DefaultUpdatedAt = itemfieldDescUpdatedAt.Default.(func() time.Time)
// itemfield.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
itemfield.UpdateDefaultUpdatedAt = itemfieldDescUpdatedAt.UpdateDefault.(func() time.Time)
// itemfieldDescName is the schema descriptor for name field.
itemfieldDescName := itemfieldMixinFields1[0].Descriptor()
// itemfield.NameValidator is a validator for the "name" field. It is called by the builders before save.
itemfield.NameValidator = func() func(string) error {
validators := itemfieldDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// itemfieldDescDescription is the schema descriptor for description field.
itemfieldDescDescription := itemfieldMixinFields1[1].Descriptor()
// itemfield.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
itemfield.DescriptionValidator = itemfieldDescDescription.Validators[0].(func(string) error)
// itemfieldDescTextValue is the schema descriptor for text_value field.
itemfieldDescTextValue := itemfieldFields[1].Descriptor()
// itemfield.TextValueValidator is a validator for the "text_value" field. It is called by the builders before save.
itemfield.TextValueValidator = itemfieldDescTextValue.Validators[0].(func(string) error)
// itemfieldDescBooleanValue is the schema descriptor for boolean_value field.
itemfieldDescBooleanValue := itemfieldFields[3].Descriptor()
// itemfield.DefaultBooleanValue holds the default value on creation for the boolean_value field.
itemfield.DefaultBooleanValue = itemfieldDescBooleanValue.Default.(bool)
// itemfieldDescTimeValue is the schema descriptor for time_value field.
itemfieldDescTimeValue := itemfieldFields[4].Descriptor()
// itemfield.DefaultTimeValue holds the default value on creation for the time_value field.
itemfield.DefaultTimeValue = itemfieldDescTimeValue.Default.(func() time.Time)
// itemfieldDescID is the schema descriptor for id field.
itemfieldDescID := itemfieldMixinFields0[0].Descriptor()
// itemfield.DefaultID holds the default value on creation for the id field.
itemfield.DefaultID = itemfieldDescID.Default.(func() uuid.UUID)
itemtemplateMixin := schema.ItemTemplate{}.Mixin()
itemtemplateMixinFields0 := itemtemplateMixin[0].Fields()
_ = itemtemplateMixinFields0
@@ -450,49 +505,6 @@ func init() {
labelDescID := labelMixinFields0[0].Descriptor()
// label.DefaultID holds the default value on creation for the id field.
label.DefaultID = labelDescID.Default.(func() uuid.UUID)
locationMixin := schema.Location{}.Mixin()
locationMixinFields0 := locationMixin[0].Fields()
_ = locationMixinFields0
locationMixinFields1 := locationMixin[1].Fields()
_ = locationMixinFields1
locationFields := schema.Location{}.Fields()
_ = locationFields
// locationDescCreatedAt is the schema descriptor for created_at field.
locationDescCreatedAt := locationMixinFields0[1].Descriptor()
// location.DefaultCreatedAt holds the default value on creation for the created_at field.
location.DefaultCreatedAt = locationDescCreatedAt.Default.(func() time.Time)
// locationDescUpdatedAt is the schema descriptor for updated_at field.
locationDescUpdatedAt := locationMixinFields0[2].Descriptor()
// location.DefaultUpdatedAt holds the default value on creation for the updated_at field.
location.DefaultUpdatedAt = locationDescUpdatedAt.Default.(func() time.Time)
// location.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
location.UpdateDefaultUpdatedAt = locationDescUpdatedAt.UpdateDefault.(func() time.Time)
// locationDescName is the schema descriptor for name field.
locationDescName := locationMixinFields1[0].Descriptor()
// location.NameValidator is a validator for the "name" field. It is called by the builders before save.
location.NameValidator = func() func(string) error {
validators := locationDescName.Validators
fns := [...]func(string) error{
validators[0].(func(string) error),
validators[1].(func(string) error),
}
return func(name string) error {
for _, fn := range fns {
if err := fn(name); err != nil {
return err
}
}
return nil
}
}()
// locationDescDescription is the schema descriptor for description field.
locationDescDescription := locationMixinFields1[1].Descriptor()
// location.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
location.DescriptionValidator = locationDescDescription.Validators[0].(func(string) error)
// locationDescID is the schema descriptor for id field.
locationDescID := locationMixinFields0[0].Descriptor()
// location.DefaultID holds the default value on creation for the id field.
location.DefaultID = locationDescID.Default.(func() uuid.UUID)
maintenanceentryMixin := schema.MaintenanceEntry{}.Mixin()
maintenanceentryMixinFields0 := maintenanceentryMixin[0].Fields()
_ = maintenanceentryMixinFields0

View File

@@ -43,8 +43,7 @@ func (Group) Edges() []ent.Edge {
return []ent.Edge{
owned("users", User.Type),
owned("locations", Location.Type),
owned("items", Item.Type),
owned("entities", Entity.Type),
owned("labels", Label.Type),
owned("invitation_tokens", GroupInvitationToken.Type),
owned("notifiers", Notifier.Type),

View File

@@ -105,7 +105,7 @@ func (ItemTemplate) Edges() []ent.Edge {
return []ent.Edge{
owned("fields", TemplateField.Type),
// Default location for items created from this template
edge.To("location", Location.Type).
edge.To("location", Entity.Type).
Unique(),
}
}

View File

@@ -18,20 +18,20 @@ type Tx struct {
AuthRoles *AuthRolesClient
// AuthTokens is the client for interacting with the AuthTokens builders.
AuthTokens *AuthTokensClient
// Entity is the client for interacting with the Entity builders.
Entity *EntityClient
// EntityField is the client for interacting with the EntityField builders.
EntityField *EntityFieldClient
// EntityType is the client for interacting with the EntityType builders.
EntityType *EntityTypeClient
// Group is the client for interacting with the Group builders.
Group *GroupClient
// GroupInvitationToken is the client for interacting with the GroupInvitationToken builders.
GroupInvitationToken *GroupInvitationTokenClient
// Item is the client for interacting with the Item builders.
Item *ItemClient
// ItemField is the client for interacting with the ItemField builders.
ItemField *ItemFieldClient
// ItemTemplate is the client for interacting with the ItemTemplate builders.
ItemTemplate *ItemTemplateClient
// Label is the client for interacting with the Label builders.
Label *LabelClient
// Location is the client for interacting with the Location builders.
Location *LocationClient
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
MaintenanceEntry *MaintenanceEntryClient
// Notifier is the client for interacting with the Notifier builders.
@@ -174,13 +174,13 @@ func (tx *Tx) init() {
tx.Attachment = NewAttachmentClient(tx.config)
tx.AuthRoles = NewAuthRolesClient(tx.config)
tx.AuthTokens = NewAuthTokensClient(tx.config)
tx.Entity = NewEntityClient(tx.config)
tx.EntityField = NewEntityFieldClient(tx.config)
tx.EntityType = NewEntityTypeClient(tx.config)
tx.Group = NewGroupClient(tx.config)
tx.GroupInvitationToken = NewGroupInvitationTokenClient(tx.config)
tx.Item = NewItemClient(tx.config)
tx.ItemField = NewItemFieldClient(tx.config)
tx.ItemTemplate = NewItemTemplateClient(tx.config)
tx.Label = NewLabelClient(tx.config)
tx.Location = NewLocationClient(tx.config)
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
tx.Notifier = NewNotifierClient(tx.config)
tx.TemplateField = NewTemplateFieldClient(tx.config)