pcmt/ent/hibp_delete.go
surtur 50e7596672
All checks were successful
continuous-integration/drone/push Build is passing
chore(ent): re-run go generate
2023-08-07 21:31:46 +02:00

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