mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 00:30:27 +00:00
update edges
This commit is contained in:
parent
c547678e36
commit
f6ed3646bf
13 changed files with 476 additions and 482 deletions
|
@ -930,6 +930,22 @@ func (c *ItemClient) QueryGroup(i *Item) *GroupQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryLabel queries the label edge of a Item.
|
||||
func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
|
||||
query := &LabelQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(i.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLocation queries the location edge of a Item.
|
||||
func (c *ItemClient) QueryLocation(i *Item) *LocationQuery {
|
||||
query := &LocationQuery{config: c.config}
|
||||
|
@ -962,22 +978,6 @@ func (c *ItemClient) QueryFields(i *Item) *ItemFieldQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryLabel queries the label edge of a Item.
|
||||
func (c *ItemClient) QueryLabel(i *Item) *LabelQuery {
|
||||
query := &LabelQuery{config: c.config}
|
||||
query.path = func(ctx context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := i.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(i.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAttachments queries the attachments edge of a Item.
|
||||
func (c *ItemClient) QueryAttachments(i *Item) *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: c.config}
|
||||
|
|
|
@ -72,12 +72,12 @@ type Item struct {
|
|||
type ItemEdges struct {
|
||||
// Group holds the value of the group edge.
|
||||
Group *Group `json:"group,omitempty"`
|
||||
// Label holds the value of the label edge.
|
||||
Label []*Label `json:"label,omitempty"`
|
||||
// Location holds the value of the location edge.
|
||||
Location *Location `json:"location,omitempty"`
|
||||
// Fields holds the value of the fields edge.
|
||||
Fields []*ItemField `json:"fields,omitempty"`
|
||||
// Label holds the value of the label edge.
|
||||
Label []*Label `json:"label,omitempty"`
|
||||
// Attachments holds the value of the attachments edge.
|
||||
Attachments []*Attachment `json:"attachments,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
|
@ -98,10 +98,19 @@ func (e ItemEdges) GroupOrErr() (*Group, error) {
|
|||
return nil, &NotLoadedError{edge: "group"}
|
||||
}
|
||||
|
||||
// LabelOrErr returns the Label value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Label, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "label"}
|
||||
}
|
||||
|
||||
// LocationOrErr returns the Location value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e ItemEdges) LocationOrErr() (*Location, error) {
|
||||
if e.loadedTypes[1] {
|
||||
if e.loadedTypes[2] {
|
||||
if e.Location == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: location.Label}
|
||||
|
@ -114,21 +123,12 @@ func (e ItemEdges) LocationOrErr() (*Location, error) {
|
|||
// FieldsOrErr returns the Fields value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemEdges) FieldsOrErr() ([]*ItemField, error) {
|
||||
if e.loadedTypes[2] {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Fields, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "fields"}
|
||||
}
|
||||
|
||||
// LabelOrErr returns the Label value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Label, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "label"}
|
||||
}
|
||||
|
||||
// AttachmentsOrErr returns the Attachments value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemEdges) AttachmentsOrErr() ([]*Attachment, error) {
|
||||
|
@ -330,6 +330,11 @@ func (i *Item) QueryGroup() *GroupQuery {
|
|||
return (&ItemClient{config: i.config}).QueryGroup(i)
|
||||
}
|
||||
|
||||
// QueryLabel queries the "label" edge of the Item entity.
|
||||
func (i *Item) QueryLabel() *LabelQuery {
|
||||
return (&ItemClient{config: i.config}).QueryLabel(i)
|
||||
}
|
||||
|
||||
// QueryLocation queries the "location" edge of the Item entity.
|
||||
func (i *Item) QueryLocation() *LocationQuery {
|
||||
return (&ItemClient{config: i.config}).QueryLocation(i)
|
||||
|
@ -340,11 +345,6 @@ func (i *Item) QueryFields() *ItemFieldQuery {
|
|||
return (&ItemClient{config: i.config}).QueryFields(i)
|
||||
}
|
||||
|
||||
// QueryLabel queries the "label" edge of the Item entity.
|
||||
func (i *Item) QueryLabel() *LabelQuery {
|
||||
return (&ItemClient{config: i.config}).QueryLabel(i)
|
||||
}
|
||||
|
||||
// QueryAttachments queries the "attachments" edge of the Item entity.
|
||||
func (i *Item) QueryAttachments() *AttachmentQuery {
|
||||
return (&ItemClient{config: i.config}).QueryAttachments(i)
|
||||
|
|
|
@ -57,12 +57,12 @@ const (
|
|||
FieldSoldNotes = "sold_notes"
|
||||
// EdgeGroup holds the string denoting the group edge name in mutations.
|
||||
EdgeGroup = "group"
|
||||
// EdgeLabel holds the string denoting the label edge name in mutations.
|
||||
EdgeLabel = "label"
|
||||
// EdgeLocation holds the string denoting the location edge name in mutations.
|
||||
EdgeLocation = "location"
|
||||
// EdgeFields holds the string denoting the fields edge name in mutations.
|
||||
EdgeFields = "fields"
|
||||
// EdgeLabel holds the string denoting the label edge name in mutations.
|
||||
EdgeLabel = "label"
|
||||
// EdgeAttachments holds the string denoting the attachments edge name in mutations.
|
||||
EdgeAttachments = "attachments"
|
||||
// Table holds the table name of the item in the database.
|
||||
|
@ -74,6 +74,11 @@ const (
|
|||
GroupInverseTable = "groups"
|
||||
// GroupColumn is the table column denoting the group relation/edge.
|
||||
GroupColumn = "group_items"
|
||||
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
|
||||
LabelTable = "label_items"
|
||||
// LabelInverseTable is the table name for the Label entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "label" package.
|
||||
LabelInverseTable = "labels"
|
||||
// LocationTable is the table that holds the location relation/edge.
|
||||
LocationTable = "items"
|
||||
// LocationInverseTable is the table name for the Location entity.
|
||||
|
@ -88,11 +93,6 @@ const (
|
|||
FieldsInverseTable = "item_fields"
|
||||
// FieldsColumn is the table column denoting the fields relation/edge.
|
||||
FieldsColumn = "item_fields"
|
||||
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
|
||||
LabelTable = "label_items"
|
||||
// LabelInverseTable is the table name for the Label entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "label" package.
|
||||
LabelInverseTable = "labels"
|
||||
// AttachmentsTable is the table that holds the attachments relation/edge.
|
||||
AttachmentsTable = "attachments"
|
||||
// AttachmentsInverseTable is the table name for the Attachment entity.
|
||||
|
|
|
@ -2068,6 +2068,34 @@ func HasGroupWith(preds ...predicate.Group) predicate.Item {
|
|||
})
|
||||
}
|
||||
|
||||
// HasLabel applies the HasEdge predicate on the "label" edge.
|
||||
func HasLabel() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LabelTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasLabelWith applies the HasEdge predicate on the "label" edge with a given conditions (other predicates).
|
||||
func HasLabelWith(preds ...predicate.Label) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LabelInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasLocation applies the HasEdge predicate on the "location" edge.
|
||||
func HasLocation() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
|
@ -2124,34 +2152,6 @@ func HasFieldsWith(preds ...predicate.ItemField) predicate.Item {
|
|||
})
|
||||
}
|
||||
|
||||
// HasLabel applies the HasEdge predicate on the "label" edge.
|
||||
func HasLabel() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LabelTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasLabelWith applies the HasEdge predicate on the "label" edge with a given conditions (other predicates).
|
||||
func HasLabelWith(preds ...predicate.Label) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(LabelInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasAttachments applies the HasEdge predicate on the "attachments" edge.
|
||||
func HasAttachments() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
|
|
|
@ -337,6 +337,21 @@ func (ic *ItemCreate) SetGroup(g *Group) *ItemCreate {
|
|||
return ic.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (ic *ItemCreate) AddLabelIDs(ids ...uuid.UUID) *ItemCreate {
|
||||
ic.mutation.AddLabelIDs(ids...)
|
||||
return ic
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (ic *ItemCreate) AddLabel(l ...*Label) *ItemCreate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return ic.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
func (ic *ItemCreate) SetLocationID(id uuid.UUID) *ItemCreate {
|
||||
ic.mutation.SetLocationID(id)
|
||||
|
@ -371,21 +386,6 @@ func (ic *ItemCreate) AddFields(i ...*ItemField) *ItemCreate {
|
|||
return ic.AddFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (ic *ItemCreate) AddLabelIDs(ids ...uuid.UUID) *ItemCreate {
|
||||
ic.mutation.AddLabelIDs(ids...)
|
||||
return ic
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (ic *ItemCreate) AddLabel(l ...*Label) *ItemCreate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return ic.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
||||
func (ic *ItemCreate) AddAttachmentIDs(ids ...uuid.UUID) *ItemCreate {
|
||||
ic.mutation.AddAttachmentIDs(ids...)
|
||||
|
@ -810,6 +810,25 @@ func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
|
|||
_node.group_items = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := ic.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := ic.mutation.LocationIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -849,25 +868,6 @@ func (ic *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
|
|||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := ic.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := ic.mutation.AttachmentsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
|
|
@ -31,9 +31,9 @@ type ItemQuery struct {
|
|||
fields []string
|
||||
predicates []predicate.Item
|
||||
withGroup *GroupQuery
|
||||
withLabel *LabelQuery
|
||||
withLocation *LocationQuery
|
||||
withFields *ItemFieldQuery
|
||||
withLabel *LabelQuery
|
||||
withAttachments *AttachmentQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
|
@ -94,6 +94,28 @@ func (iq *ItemQuery) QueryGroup() *GroupQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryLabel chains the current query on the "label" edge.
|
||||
func (iq *ItemQuery) QueryLabel() *LabelQuery {
|
||||
query := &LabelQuery{config: iq.config}
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := iq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := iq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, selector),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryLocation chains the current query on the "location" edge.
|
||||
func (iq *ItemQuery) QueryLocation() *LocationQuery {
|
||||
query := &LocationQuery{config: iq.config}
|
||||
|
@ -138,28 +160,6 @@ func (iq *ItemQuery) QueryFields() *ItemFieldQuery {
|
|||
return query
|
||||
}
|
||||
|
||||
// QueryLabel chains the current query on the "label" edge.
|
||||
func (iq *ItemQuery) QueryLabel() *LabelQuery {
|
||||
query := &LabelQuery{config: iq.config}
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := iq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := iq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, selector),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(iq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryAttachments chains the current query on the "attachments" edge.
|
||||
func (iq *ItemQuery) QueryAttachments() *AttachmentQuery {
|
||||
query := &AttachmentQuery{config: iq.config}
|
||||
|
@ -364,9 +364,9 @@ func (iq *ItemQuery) Clone() *ItemQuery {
|
|||
order: append([]OrderFunc{}, iq.order...),
|
||||
predicates: append([]predicate.Item{}, iq.predicates...),
|
||||
withGroup: iq.withGroup.Clone(),
|
||||
withLabel: iq.withLabel.Clone(),
|
||||
withLocation: iq.withLocation.Clone(),
|
||||
withFields: iq.withFields.Clone(),
|
||||
withLabel: iq.withLabel.Clone(),
|
||||
withAttachments: iq.withAttachments.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: iq.sql.Clone(),
|
||||
|
@ -386,6 +386,17 @@ func (iq *ItemQuery) WithGroup(opts ...func(*GroupQuery)) *ItemQuery {
|
|||
return iq
|
||||
}
|
||||
|
||||
// WithLabel tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "label" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (iq *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery {
|
||||
query := &LabelQuery{config: iq.config}
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
iq.withLabel = query
|
||||
return iq
|
||||
}
|
||||
|
||||
// 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 (iq *ItemQuery) WithLocation(opts ...func(*LocationQuery)) *ItemQuery {
|
||||
|
@ -408,17 +419,6 @@ func (iq *ItemQuery) WithFields(opts ...func(*ItemFieldQuery)) *ItemQuery {
|
|||
return iq
|
||||
}
|
||||
|
||||
// WithLabel tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "label" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (iq *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery {
|
||||
query := &LabelQuery{config: iq.config}
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
iq.withLabel = query
|
||||
return iq
|
||||
}
|
||||
|
||||
// WithAttachments tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "attachments" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (iq *ItemQuery) WithAttachments(opts ...func(*AttachmentQuery)) *ItemQuery {
|
||||
|
@ -501,9 +501,9 @@ func (iq *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, e
|
|||
_spec = iq.querySpec()
|
||||
loadedTypes = [5]bool{
|
||||
iq.withGroup != nil,
|
||||
iq.withLabel != nil,
|
||||
iq.withLocation != nil,
|
||||
iq.withFields != nil,
|
||||
iq.withLabel != nil,
|
||||
iq.withAttachments != nil,
|
||||
}
|
||||
)
|
||||
|
@ -537,6 +537,13 @@ func (iq *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, e
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := iq.withLabel; query != nil {
|
||||
if err := iq.loadLabel(ctx, query, nodes,
|
||||
func(n *Item) { n.Edges.Label = []*Label{} },
|
||||
func(n *Item, e *Label) { n.Edges.Label = append(n.Edges.Label, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := iq.withLocation; query != nil {
|
||||
if err := iq.loadLocation(ctx, query, nodes, nil,
|
||||
func(n *Item, e *Location) { n.Edges.Location = e }); err != nil {
|
||||
|
@ -550,13 +557,6 @@ func (iq *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, e
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := iq.withLabel; query != nil {
|
||||
if err := iq.loadLabel(ctx, query, nodes,
|
||||
func(n *Item) { n.Edges.Label = []*Label{} },
|
||||
func(n *Item, e *Label) { n.Edges.Label = append(n.Edges.Label, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := iq.withAttachments; query != nil {
|
||||
if err := iq.loadAttachments(ctx, query, nodes,
|
||||
func(n *Item) { n.Edges.Attachments = []*Attachment{} },
|
||||
|
@ -596,6 +596,64 @@ func (iq *ItemQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (iq *ItemQuery) loadLabel(ctx context.Context, query *LabelQuery, nodes []*Item, init func(*Item), assign func(*Item, *Label)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uuid.UUID]*Item)
|
||||
nids := make(map[uuid.UUID]map[*Item]struct{})
|
||||
for i, node := range nodes {
|
||||
edgeIDs[i] = node.ID
|
||||
byID[node.ID] = node
|
||||
if init != nil {
|
||||
init(node)
|
||||
}
|
||||
}
|
||||
query.Where(func(s *sql.Selector) {
|
||||
joinT := sql.Table(item.LabelTable)
|
||||
s.Join(joinT).On(s.C(label.FieldID), joinT.C(item.LabelPrimaryKey[0]))
|
||||
s.Where(sql.InValues(joinT.C(item.LabelPrimaryKey[1]), edgeIDs...))
|
||||
columns := s.SelectedColumns()
|
||||
s.Select(joinT.C(item.LabelPrimaryKey[1]))
|
||||
s.AppendSelect(columns...)
|
||||
s.SetDistinct(false)
|
||||
})
|
||||
if err := query.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
|
||||
assign := spec.Assign
|
||||
values := spec.ScanValues
|
||||
spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
values, err := values(columns[1:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append([]any{new(uuid.UUID)}, values...), nil
|
||||
}
|
||||
spec.Assign = func(columns []string, values []any) error {
|
||||
outValue := *values[0].(*uuid.UUID)
|
||||
inValue := *values[1].(*uuid.UUID)
|
||||
if nids[inValue] == nil {
|
||||
nids[inValue] = map[*Item]struct{}{byID[outValue]: struct{}{}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected "label" node returned %v`, n.ID)
|
||||
}
|
||||
for kn := range nodes {
|
||||
assign(kn, n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (iq *ItemQuery) loadLocation(ctx context.Context, query *LocationQuery, nodes []*Item, init func(*Item), assign func(*Item, *Location)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Item)
|
||||
|
@ -656,64 +714,6 @@ func (iq *ItemQuery) loadFields(ctx context.Context, query *ItemFieldQuery, node
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (iq *ItemQuery) loadLabel(ctx context.Context, query *LabelQuery, nodes []*Item, init func(*Item), assign func(*Item, *Label)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uuid.UUID]*Item)
|
||||
nids := make(map[uuid.UUID]map[*Item]struct{})
|
||||
for i, node := range nodes {
|
||||
edgeIDs[i] = node.ID
|
||||
byID[node.ID] = node
|
||||
if init != nil {
|
||||
init(node)
|
||||
}
|
||||
}
|
||||
query.Where(func(s *sql.Selector) {
|
||||
joinT := sql.Table(item.LabelTable)
|
||||
s.Join(joinT).On(s.C(label.FieldID), joinT.C(item.LabelPrimaryKey[0]))
|
||||
s.Where(sql.InValues(joinT.C(item.LabelPrimaryKey[1]), edgeIDs...))
|
||||
columns := s.SelectedColumns()
|
||||
s.Select(joinT.C(item.LabelPrimaryKey[1]))
|
||||
s.AppendSelect(columns...)
|
||||
s.SetDistinct(false)
|
||||
})
|
||||
if err := query.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
|
||||
assign := spec.Assign
|
||||
values := spec.ScanValues
|
||||
spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
values, err := values(columns[1:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return append([]any{new(uuid.UUID)}, values...), nil
|
||||
}
|
||||
spec.Assign = func(columns []string, values []any) error {
|
||||
outValue := *values[0].(*uuid.UUID)
|
||||
inValue := *values[1].(*uuid.UUID)
|
||||
if nids[inValue] == nil {
|
||||
nids[inValue] = map[*Item]struct{}{byID[outValue]: struct{}{}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
return nil
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected "label" node returned %v`, n.ID)
|
||||
}
|
||||
for kn := range nodes {
|
||||
assign(kn, n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (iq *ItemQuery) loadAttachments(ctx context.Context, query *AttachmentQuery, nodes []*Item, init func(*Item), assign func(*Item, *Attachment)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Item)
|
||||
|
|
|
@ -388,6 +388,21 @@ func (iu *ItemUpdate) SetGroup(g *Group) *ItemUpdate {
|
|||
return iu.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iu *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.AddLabelIDs(ids...)
|
||||
return iu
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (iu *ItemUpdate) AddLabel(l ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iu.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
func (iu *ItemUpdate) SetLocationID(id uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.SetLocationID(id)
|
||||
|
@ -422,21 +437,6 @@ func (iu *ItemUpdate) AddFields(i ...*ItemField) *ItemUpdate {
|
|||
return iu.AddFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iu *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.AddLabelIDs(ids...)
|
||||
return iu
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (iu *ItemUpdate) AddLabel(l ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iu.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
||||
func (iu *ItemUpdate) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.AddAttachmentIDs(ids...)
|
||||
|
@ -463,6 +463,27 @@ func (iu *ItemUpdate) ClearGroup() *ItemUpdate {
|
|||
return iu
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iu *ItemUpdate) ClearLabel() *ItemUpdate {
|
||||
iu.mutation.ClearLabel()
|
||||
return iu
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (iu *ItemUpdate) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.RemoveLabelIDs(ids...)
|
||||
return iu
|
||||
}
|
||||
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (iu *ItemUpdate) RemoveLabel(l ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iu.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLocation clears the "location" edge to the Location entity.
|
||||
func (iu *ItemUpdate) ClearLocation() *ItemUpdate {
|
||||
iu.mutation.ClearLocation()
|
||||
|
@ -490,27 +511,6 @@ func (iu *ItemUpdate) RemoveFields(i ...*ItemField) *ItemUpdate {
|
|||
return iu.RemoveFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iu *ItemUpdate) ClearLabel() *ItemUpdate {
|
||||
iu.mutation.ClearLabel()
|
||||
return iu
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (iu *ItemUpdate) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
iu.mutation.RemoveLabelIDs(ids...)
|
||||
return iu
|
||||
}
|
||||
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (iu *ItemUpdate) RemoveLabel(l ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iu.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
||||
func (iu *ItemUpdate) ClearAttachments() *ItemUpdate {
|
||||
iu.mutation.ClearAttachments()
|
||||
|
@ -934,6 +934,60 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.RemovedLabelIDs(); len(nodes) > 0 && !iu.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.LocationCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -1023,60 +1077,6 @@ func (iu *ItemUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.RemovedLabelIDs(); len(nodes) > 0 && !iu.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iu.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iu.mutation.AttachmentsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
@ -1504,6 +1504,21 @@ func (iuo *ItemUpdateOne) SetGroup(g *Group) *ItemUpdateOne {
|
|||
return iuo.SetGroupID(g.ID)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iuo *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.AddLabelIDs(ids...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (iuo *ItemUpdateOne) AddLabel(l ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iuo.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
func (iuo *ItemUpdateOne) SetLocationID(id uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.SetLocationID(id)
|
||||
|
@ -1538,21 +1553,6 @@ func (iuo *ItemUpdateOne) AddFields(i ...*ItemField) *ItemUpdateOne {
|
|||
return iuo.AddFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (iuo *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.AddLabelIDs(ids...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (iuo *ItemUpdateOne) AddLabel(l ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iuo.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by IDs.
|
||||
func (iuo *ItemUpdateOne) AddAttachmentIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.AddAttachmentIDs(ids...)
|
||||
|
@ -1579,6 +1579,27 @@ func (iuo *ItemUpdateOne) ClearGroup() *ItemUpdateOne {
|
|||
return iuo
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iuo *ItemUpdateOne) ClearLabel() *ItemUpdateOne {
|
||||
iuo.mutation.ClearLabel()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (iuo *ItemUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.RemoveLabelIDs(ids...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (iuo *ItemUpdateOne) RemoveLabel(l ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iuo.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLocation clears the "location" edge to the Location entity.
|
||||
func (iuo *ItemUpdateOne) ClearLocation() *ItemUpdateOne {
|
||||
iuo.mutation.ClearLocation()
|
||||
|
@ -1606,27 +1627,6 @@ func (iuo *ItemUpdateOne) RemoveFields(i ...*ItemField) *ItemUpdateOne {
|
|||
return iuo.RemoveFieldIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (iuo *ItemUpdateOne) ClearLabel() *ItemUpdateOne {
|
||||
iuo.mutation.ClearLabel()
|
||||
return iuo
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (iuo *ItemUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
iuo.mutation.RemoveLabelIDs(ids...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (iuo *ItemUpdateOne) RemoveLabel(l ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(l))
|
||||
for i := range l {
|
||||
ids[i] = l[i].ID
|
||||
}
|
||||
return iuo.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearAttachments clears all "attachments" edges to the Attachment entity.
|
||||
func (iuo *ItemUpdateOne) ClearAttachments() *ItemUpdateOne {
|
||||
iuo.mutation.ClearAttachments()
|
||||
|
@ -2080,6 +2080,60 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.RemovedLabelIDs(); len(nodes) > 0 && !iuo.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.LocationCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
|
@ -2169,60 +2223,6 @@ func (iuo *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error)
|
|||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.RemovedLabelIDs(); len(nodes) > 0 && !iuo.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := iuo.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: label.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if iuo.mutation.AttachmentsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
|
|
|
@ -3430,14 +3430,14 @@ type ItemMutation struct {
|
|||
clearedFields map[string]struct{}
|
||||
group *uuid.UUID
|
||||
clearedgroup bool
|
||||
label map[uuid.UUID]struct{}
|
||||
removedlabel map[uuid.UUID]struct{}
|
||||
clearedlabel bool
|
||||
location *uuid.UUID
|
||||
clearedlocation bool
|
||||
fields map[uuid.UUID]struct{}
|
||||
removedfields map[uuid.UUID]struct{}
|
||||
clearedfields bool
|
||||
label map[uuid.UUID]struct{}
|
||||
removedlabel map[uuid.UUID]struct{}
|
||||
clearedlabel bool
|
||||
attachments map[uuid.UUID]struct{}
|
||||
removedattachments map[uuid.UUID]struct{}
|
||||
clearedattachments bool
|
||||
|
@ -4574,6 +4574,60 @@ func (m *ItemMutation) ResetGroup() {
|
|||
m.clearedgroup = false
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by ids.
|
||||
func (m *ItemMutation) AddLabelIDs(ids ...uuid.UUID) {
|
||||
if m.label == nil {
|
||||
m.label = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.label[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// ClearLabel clears the "label" edge to the Label entity.
|
||||
func (m *ItemMutation) ClearLabel() {
|
||||
m.clearedlabel = true
|
||||
}
|
||||
|
||||
// LabelCleared reports if the "label" edge to the Label entity was cleared.
|
||||
func (m *ItemMutation) LabelCleared() bool {
|
||||
return m.clearedlabel
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to the Label entity by IDs.
|
||||
func (m *ItemMutation) RemoveLabelIDs(ids ...uuid.UUID) {
|
||||
if m.removedlabel == nil {
|
||||
m.removedlabel = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.label, ids[i])
|
||||
m.removedlabel[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// RemovedLabel returns the removed IDs of the "label" edge to the Label entity.
|
||||
func (m *ItemMutation) RemovedLabelIDs() (ids []uuid.UUID) {
|
||||
for id := range m.removedlabel {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// LabelIDs returns the "label" edge IDs in the mutation.
|
||||
func (m *ItemMutation) LabelIDs() (ids []uuid.UUID) {
|
||||
for id := range m.label {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetLabel resets all changes to the "label" edge.
|
||||
func (m *ItemMutation) ResetLabel() {
|
||||
m.label = nil
|
||||
m.clearedlabel = false
|
||||
m.removedlabel = nil
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by id.
|
||||
func (m *ItemMutation) SetLocationID(id uuid.UUID) {
|
||||
m.location = &id
|
||||
|
@ -4667,60 +4721,6 @@ func (m *ItemMutation) ResetFields() {
|
|||
m.removedfields = nil
|
||||
}
|
||||
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by ids.
|
||||
func (m *ItemMutation) AddLabelIDs(ids ...uuid.UUID) {
|
||||
if m.label == nil {
|
||||
m.label = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.label[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// ClearLabel clears the "label" edge to the Label entity.
|
||||
func (m *ItemMutation) ClearLabel() {
|
||||
m.clearedlabel = true
|
||||
}
|
||||
|
||||
// LabelCleared reports if the "label" edge to the Label entity was cleared.
|
||||
func (m *ItemMutation) LabelCleared() bool {
|
||||
return m.clearedlabel
|
||||
}
|
||||
|
||||
// RemoveLabelIDs removes the "label" edge to the Label entity by IDs.
|
||||
func (m *ItemMutation) RemoveLabelIDs(ids ...uuid.UUID) {
|
||||
if m.removedlabel == nil {
|
||||
m.removedlabel = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.label, ids[i])
|
||||
m.removedlabel[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// RemovedLabel returns the removed IDs of the "label" edge to the Label entity.
|
||||
func (m *ItemMutation) RemovedLabelIDs() (ids []uuid.UUID) {
|
||||
for id := range m.removedlabel {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// LabelIDs returns the "label" edge IDs in the mutation.
|
||||
func (m *ItemMutation) LabelIDs() (ids []uuid.UUID) {
|
||||
for id := range m.label {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetLabel resets all changes to the "label" edge.
|
||||
func (m *ItemMutation) ResetLabel() {
|
||||
m.label = nil
|
||||
m.clearedlabel = false
|
||||
m.removedlabel = nil
|
||||
}
|
||||
|
||||
// AddAttachmentIDs adds the "attachments" edge to the Attachment entity by ids.
|
||||
func (m *ItemMutation) AddAttachmentIDs(ids ...uuid.UUID) {
|
||||
if m.attachments == nil {
|
||||
|
@ -5357,15 +5357,15 @@ func (m *ItemMutation) AddedEdges() []string {
|
|||
if m.group != nil {
|
||||
edges = append(edges, item.EdgeGroup)
|
||||
}
|
||||
if m.label != nil {
|
||||
edges = append(edges, item.EdgeLabel)
|
||||
}
|
||||
if m.location != nil {
|
||||
edges = append(edges, item.EdgeLocation)
|
||||
}
|
||||
if m.fields != nil {
|
||||
edges = append(edges, item.EdgeFields)
|
||||
}
|
||||
if m.label != nil {
|
||||
edges = append(edges, item.EdgeLabel)
|
||||
}
|
||||
if m.attachments != nil {
|
||||
edges = append(edges, item.EdgeAttachments)
|
||||
}
|
||||
|
@ -5380,6 +5380,12 @@ func (m *ItemMutation) AddedIDs(name string) []ent.Value {
|
|||
if id := m.group; id != nil {
|
||||
return []ent.Value{*id}
|
||||
}
|
||||
case item.EdgeLabel:
|
||||
ids := make([]ent.Value, 0, len(m.label))
|
||||
for id := range m.label {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeLocation:
|
||||
if id := m.location; id != nil {
|
||||
return []ent.Value{*id}
|
||||
|
@ -5390,12 +5396,6 @@ func (m *ItemMutation) AddedIDs(name string) []ent.Value {
|
|||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeLabel:
|
||||
ids := make([]ent.Value, 0, len(m.label))
|
||||
for id := range m.label {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeAttachments:
|
||||
ids := make([]ent.Value, 0, len(m.attachments))
|
||||
for id := range m.attachments {
|
||||
|
@ -5409,12 +5409,12 @@ func (m *ItemMutation) AddedIDs(name string) []ent.Value {
|
|||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *ItemMutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 5)
|
||||
if m.removedfields != nil {
|
||||
edges = append(edges, item.EdgeFields)
|
||||
}
|
||||
if m.removedlabel != nil {
|
||||
edges = append(edges, item.EdgeLabel)
|
||||
}
|
||||
if m.removedfields != nil {
|
||||
edges = append(edges, item.EdgeFields)
|
||||
}
|
||||
if m.removedattachments != nil {
|
||||
edges = append(edges, item.EdgeAttachments)
|
||||
}
|
||||
|
@ -5425,18 +5425,18 @@ func (m *ItemMutation) RemovedEdges() []string {
|
|||
// the given name in this mutation.
|
||||
func (m *ItemMutation) RemovedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case item.EdgeFields:
|
||||
ids := make([]ent.Value, 0, len(m.removedfields))
|
||||
for id := range m.removedfields {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeLabel:
|
||||
ids := make([]ent.Value, 0, len(m.removedlabel))
|
||||
for id := range m.removedlabel {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeFields:
|
||||
ids := make([]ent.Value, 0, len(m.removedfields))
|
||||
for id := range m.removedfields {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
case item.EdgeAttachments:
|
||||
ids := make([]ent.Value, 0, len(m.removedattachments))
|
||||
for id := range m.removedattachments {
|
||||
|
@ -5453,15 +5453,15 @@ func (m *ItemMutation) ClearedEdges() []string {
|
|||
if m.clearedgroup {
|
||||
edges = append(edges, item.EdgeGroup)
|
||||
}
|
||||
if m.clearedlabel {
|
||||
edges = append(edges, item.EdgeLabel)
|
||||
}
|
||||
if m.clearedlocation {
|
||||
edges = append(edges, item.EdgeLocation)
|
||||
}
|
||||
if m.clearedfields {
|
||||
edges = append(edges, item.EdgeFields)
|
||||
}
|
||||
if m.clearedlabel {
|
||||
edges = append(edges, item.EdgeLabel)
|
||||
}
|
||||
if m.clearedattachments {
|
||||
edges = append(edges, item.EdgeAttachments)
|
||||
}
|
||||
|
@ -5474,12 +5474,12 @@ func (m *ItemMutation) EdgeCleared(name string) bool {
|
|||
switch name {
|
||||
case item.EdgeGroup:
|
||||
return m.clearedgroup
|
||||
case item.EdgeLabel:
|
||||
return m.clearedlabel
|
||||
case item.EdgeLocation:
|
||||
return m.clearedlocation
|
||||
case item.EdgeFields:
|
||||
return m.clearedfields
|
||||
case item.EdgeLabel:
|
||||
return m.clearedlabel
|
||||
case item.EdgeAttachments:
|
||||
return m.clearedattachments
|
||||
}
|
||||
|
@ -5507,15 +5507,15 @@ func (m *ItemMutation) ResetEdge(name string) error {
|
|||
case item.EdgeGroup:
|
||||
m.ResetGroup()
|
||||
return nil
|
||||
case item.EdgeLabel:
|
||||
m.ResetLabel()
|
||||
return nil
|
||||
case item.EdgeLocation:
|
||||
m.ResetLocation()
|
||||
return nil
|
||||
case item.EdgeFields:
|
||||
m.ResetFields()
|
||||
return nil
|
||||
case item.EdgeLabel:
|
||||
m.ResetLabel()
|
||||
return nil
|
||||
case item.EdgeAttachments:
|
||||
m.ResetAttachments()
|
||||
return nil
|
||||
|
|
|
@ -98,6 +98,8 @@ func (Item) Edges() []ent.Edge {
|
|||
Ref("items").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.From("label", Label.Type).
|
||||
Ref("items"),
|
||||
edge.From("location", Location.Type).
|
||||
Ref("items").
|
||||
Unique(),
|
||||
|
@ -105,11 +107,6 @@ func (Item) Edges() []ent.Edge {
|
|||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.From("label", Label.Type).
|
||||
Ref("items").
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("attachments", Attachment.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
|
|
|
@ -2,7 +2,6 @@ package schema
|
|||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/hay-kot/homebox/backend/ent/schema/mixins"
|
||||
|
@ -36,9 +35,6 @@ func (Label) Edges() []ent.Edge {
|
|||
Ref("labels").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("items", Item.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
edge.To("items", Item.Type),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ func (User) Edges() []ent.Edge {
|
|||
Ref("users").
|
||||
Required().
|
||||
Unique(),
|
||||
edge.To("auth_tokens", AuthTokens.Type).Annotations(entsql.Annotation{
|
||||
edge.To("auth_tokens", AuthTokens.Type).
|
||||
Annotations(entsql.Annotation{
|
||||
OnDelete: entsql.Cascade,
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
h1:A58dgWs4yGTcWkHBZwIedtCwK1LIWHYxqB5uKQ40f6E=
|
||||
20220928001319_init.sql h1:KOJZuCHJ5dTHHwVDGgAWyUFahBXqGtmuv4d+rxwpuX0=
|
||||
h1:ihsTwGsfNb8b/1qt+jw0OPKM8I/Bcw1J3Ise0ZFu5co=
|
||||
20220929052825_init.sql h1:ZlCqm1wzjDmofeAcSX3jE4h4VcdTNGpRg2eabztDy9Q=
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue