2023-05-05 22:52:59 +02: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"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/setup"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetupDelete is the builder for deleting a Setup entity.
|
|
|
|
type SetupDelete struct {
|
|
|
|
config
|
|
|
|
hooks []Hook
|
|
|
|
mutation *SetupMutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the SetupDelete builder.
|
|
|
|
func (sd *SetupDelete) Where(ps ...predicate.Setup) *SetupDelete {
|
|
|
|
sd.mutation.Where(ps...)
|
|
|
|
return sd
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
|
|
func (sd *SetupDelete) Exec(ctx context.Context) (int, error) {
|
2023-08-07 21:31:46 +02:00
|
|
|
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (sd *SetupDelete) ExecX(ctx context.Context) int {
|
|
|
|
n, err := sd.Exec(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return n
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sd *SetupDelete) sqlExec(ctx context.Context) (int, error) {
|
|
|
|
_spec := sqlgraph.NewDeleteSpec(setup.Table, sqlgraph.NewFieldSpec(setup.FieldID, field.TypeUUID))
|
|
|
|
if ps := sd.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
|
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
|
}
|
|
|
|
sd.mutation.done = true
|
|
|
|
return affected, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetupDeleteOne is the builder for deleting a single Setup entity.
|
|
|
|
type SetupDeleteOne struct {
|
|
|
|
sd *SetupDelete
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the SetupDelete builder.
|
|
|
|
func (sdo *SetupDeleteOne) Where(ps ...predicate.Setup) *SetupDeleteOne {
|
|
|
|
sdo.sd.mutation.Where(ps...)
|
|
|
|
return sdo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the deletion query.
|
|
|
|
func (sdo *SetupDeleteOne) Exec(ctx context.Context) error {
|
|
|
|
n, err := sdo.sd.Exec(ctx)
|
|
|
|
switch {
|
|
|
|
case err != nil:
|
|
|
|
return err
|
|
|
|
case n == 0:
|
|
|
|
return &NotFoundError{setup.Label}
|
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (sdo *SetupDeleteOne) ExecX(ctx context.Context) {
|
|
|
|
if err := sdo.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|