mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-19 05:26:31 +00:00
5bbb969763
* remove repo for document tokens * remove schema for doc tokens * fix id template and generate cmd * schema updates * code gen * bump dependencies * fix broken migrations + add maintenance entry type * spelling * remove debug logger * implement repository layer * routes * API client * wip: maintenance log * remove depreciated call
115 lines
3 KiB
Go
115 lines
3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
|
)
|
|
|
|
// MaintenanceEntryDelete is the builder for deleting a MaintenanceEntry entity.
|
|
type MaintenanceEntryDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *MaintenanceEntryMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the MaintenanceEntryDelete builder.
|
|
func (med *MaintenanceEntryDelete) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDelete {
|
|
med.mutation.Where(ps...)
|
|
return med
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (med *MaintenanceEntryDelete) Exec(ctx context.Context) (int, error) {
|
|
var (
|
|
err error
|
|
affected int
|
|
)
|
|
if len(med.hooks) == 0 {
|
|
affected, err = med.sqlExec(ctx)
|
|
} else {
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*MaintenanceEntryMutation)
|
|
if !ok {
|
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
|
}
|
|
med.mutation = mutation
|
|
affected, err = med.sqlExec(ctx)
|
|
mutation.done = true
|
|
return affected, err
|
|
})
|
|
for i := len(med.hooks) - 1; i >= 0; i-- {
|
|
if med.hooks[i] == nil {
|
|
return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
|
}
|
|
mut = med.hooks[i](mut)
|
|
}
|
|
if _, err := mut.Mutate(ctx, med.mutation); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (med *MaintenanceEntryDelete) ExecX(ctx context.Context) int {
|
|
n, err := med.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (med *MaintenanceEntryDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := &sqlgraph.DeleteSpec{
|
|
Node: &sqlgraph.NodeSpec{
|
|
Table: maintenanceentry.Table,
|
|
ID: &sqlgraph.FieldSpec{
|
|
Type: field.TypeUUID,
|
|
Column: maintenanceentry.FieldID,
|
|
},
|
|
},
|
|
}
|
|
if ps := med.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, med.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return affected, err
|
|
}
|
|
|
|
// MaintenanceEntryDeleteOne is the builder for deleting a single MaintenanceEntry entity.
|
|
type MaintenanceEntryDeleteOne struct {
|
|
med *MaintenanceEntryDelete
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (medo *MaintenanceEntryDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := medo.med.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{maintenanceentry.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (medo *MaintenanceEntryDeleteOne) ExecX(ctx context.Context) {
|
|
medo.med.ExecX(ctx)
|
|
}
|