mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 21:16:31 +00:00
96 lines
2.6 KiB
Go
96 lines
2.6 KiB
Go
// 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) {
|
|
return withHooks[int, MaintenanceEntryMutation](ctx, med.sqlExec, med.mutation, med.hooks)
|
|
}
|
|
|
|
// 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}
|
|
}
|
|
med.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// MaintenanceEntryDeleteOne is the builder for deleting a single MaintenanceEntry entity.
|
|
type MaintenanceEntryDeleteOne struct {
|
|
med *MaintenanceEntryDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the MaintenanceEntryDelete builder.
|
|
func (medo *MaintenanceEntryDeleteOne) Where(ps ...predicate.MaintenanceEntry) *MaintenanceEntryDeleteOne {
|
|
medo.med.mutation.Where(ps...)
|
|
return medo
|
|
}
|
|
|
|
// 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) {
|
|
if err := medo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|