2022-12-10 05:57:57 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"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) {
|
2023-01-19 05:44:06 +00:00
|
|
|
return withHooks[int, MaintenanceEntryMutation](ctx, med.sqlExec, med.mutation, med.hooks)
|
2022-12-10 05:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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}
|
|
|
|
}
|
2023-01-19 05:44:06 +00:00
|
|
|
med.mutation.done = true
|
2022-12-10 05:57:57 +00:00
|
|
|
return affected, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// MaintenanceEntryDeleteOne is the builder for deleting a single MaintenanceEntry entity.
|
|
|
|
type MaintenanceEntryDeleteOne struct {
|
|
|
|
med *MaintenanceEntryDelete
|
|
|
|
}
|
|
|
|
|
2023-01-28 21:03:51 +00:00
|
|
|
// Where appends a list predicates to the MaintenanceEntryDelete builder.
|
|
|
|
func (medo *MaintenanceEntryDeleteOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
|
|
|
medo.med.mutation.Where(ps...)
|
|
|
|
return medo
|
|
|
|
}
|
|
|
|
|
2022-12-10 05:57:57 +00:00
|
|
|
// 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) {
|
2023-01-28 21:03:51 +00:00
|
|
|
if err := medo.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2022-12-10 05:57:57 +00:00
|
|
|
}
|