89 lines
2.3 KiB
Go
89 lines
2.3 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"
|
||
|
"git.dotya.ml/mirre-mt/pcmt/ent/localbreach"
|
||
|
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
|
||
|
)
|
||
|
|
||
|
// LocalBreachDelete is the builder for deleting a LocalBreach entity.
|
||
|
type LocalBreachDelete struct {
|
||
|
config
|
||
|
hooks []Hook
|
||
|
mutation *LocalBreachMutation
|
||
|
}
|
||
|
|
||
|
// Where appends a list predicates to the LocalBreachDelete builder.
|
||
|
func (lbd *LocalBreachDelete) Where(ps ...predicate.LocalBreach) *LocalBreachDelete {
|
||
|
lbd.mutation.Where(ps...)
|
||
|
return lbd
|
||
|
}
|
||
|
|
||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||
|
func (lbd *LocalBreachDelete) Exec(ctx context.Context) (int, error) {
|
||
|
return withHooks(ctx, lbd.sqlExec, lbd.mutation, lbd.hooks)
|
||
|
}
|
||
|
|
||
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
func (lbd *LocalBreachDelete) ExecX(ctx context.Context) int {
|
||
|
n, err := lbd.Exec(ctx)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return n
|
||
|
}
|
||
|
|
||
|
func (lbd *LocalBreachDelete) sqlExec(ctx context.Context) (int, error) {
|
||
|
_spec := sqlgraph.NewDeleteSpec(localbreach.Table, sqlgraph.NewFieldSpec(localbreach.FieldID, field.TypeUUID))
|
||
|
if ps := lbd.mutation.predicates; len(ps) > 0 {
|
||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||
|
for i := range ps {
|
||
|
ps[i](selector)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
affected, err := sqlgraph.DeleteNodes(ctx, lbd.driver, _spec)
|
||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
}
|
||
|
lbd.mutation.done = true
|
||
|
return affected, err
|
||
|
}
|
||
|
|
||
|
// LocalBreachDeleteOne is the builder for deleting a single LocalBreach entity.
|
||
|
type LocalBreachDeleteOne struct {
|
||
|
lbd *LocalBreachDelete
|
||
|
}
|
||
|
|
||
|
// Where appends a list predicates to the LocalBreachDelete builder.
|
||
|
func (lbdo *LocalBreachDeleteOne) Where(ps ...predicate.LocalBreach) *LocalBreachDeleteOne {
|
||
|
lbdo.lbd.mutation.Where(ps...)
|
||
|
return lbdo
|
||
|
}
|
||
|
|
||
|
// Exec executes the deletion query.
|
||
|
func (lbdo *LocalBreachDeleteOne) Exec(ctx context.Context) error {
|
||
|
n, err := lbdo.lbd.Exec(ctx)
|
||
|
switch {
|
||
|
case err != nil:
|
||
|
return err
|
||
|
case n == 0:
|
||
|
return &NotFoundError{localbreach.Label}
|
||
|
default:
|
||
|
return nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
func (lbdo *LocalBreachDeleteOne) ExecX(ctx context.Context) {
|
||
|
if err := lbdo.Exec(ctx); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|