forked from mirrors/homebox
bd321af29f
* new PR tasks * add homebox to know words * formatting * bump deps * generate db models * ts errors * drop id * fix accessor * drop unused time field * change CI * add expected error * add type check * resolve serveral type errors * hoise in CI
88 lines
2.5 KiB
Go
88 lines
2.5 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.NewDeleteSpec(maintenanceentry.Table, sqlgraph.NewFieldSpec(maintenanceentry.FieldID, field.TypeUUID))
|
|
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)
|
|
}
|
|
}
|