89 lines
2.2 KiB
Go
89 lines
2.2 KiB
Go
|
// Code generated by ent, DO NOT EDIT.
|
||
|
|
||
|
package ent
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"thesis/ent/predicate"
|
||
|
"thesis/ent/validators"
|
||
|
|
||
|
"entgo.io/ent/dialect/sql"
|
||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||
|
"entgo.io/ent/schema/field"
|
||
|
)
|
||
|
|
||
|
// ValidatorsDelete is the builder for deleting a Validators entity.
|
||
|
type ValidatorsDelete struct {
|
||
|
config
|
||
|
hooks []Hook
|
||
|
mutation *ValidatorsMutation
|
||
|
}
|
||
|
|
||
|
// Where appends a list predicates to the ValidatorsDelete builder.
|
||
|
func (vd *ValidatorsDelete) Where(ps ...predicate.Validators) *ValidatorsDelete {
|
||
|
vd.mutation.Where(ps...)
|
||
|
return vd
|
||
|
}
|
||
|
|
||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||
|
func (vd *ValidatorsDelete) Exec(ctx context.Context) (int, error) {
|
||
|
return withHooks(ctx, vd.sqlExec, vd.mutation, vd.hooks)
|
||
|
}
|
||
|
|
||
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
func (vd *ValidatorsDelete) ExecX(ctx context.Context) int {
|
||
|
n, err := vd.Exec(ctx)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return n
|
||
|
}
|
||
|
|
||
|
func (vd *ValidatorsDelete) sqlExec(ctx context.Context) (int, error) {
|
||
|
_spec := sqlgraph.NewDeleteSpec(validators.Table, sqlgraph.NewFieldSpec(validators.FieldID, field.TypeInt))
|
||
|
if ps := vd.mutation.predicates; len(ps) > 0 {
|
||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||
|
for i := range ps {
|
||
|
ps[i](selector)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
affected, err := sqlgraph.DeleteNodes(ctx, vd.driver, _spec)
|
||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||
|
}
|
||
|
vd.mutation.done = true
|
||
|
return affected, err
|
||
|
}
|
||
|
|
||
|
// ValidatorsDeleteOne is the builder for deleting a single Validators entity.
|
||
|
type ValidatorsDeleteOne struct {
|
||
|
vd *ValidatorsDelete
|
||
|
}
|
||
|
|
||
|
// Where appends a list predicates to the ValidatorsDelete builder.
|
||
|
func (vdo *ValidatorsDeleteOne) Where(ps ...predicate.Validators) *ValidatorsDeleteOne {
|
||
|
vdo.vd.mutation.Where(ps...)
|
||
|
return vdo
|
||
|
}
|
||
|
|
||
|
// Exec executes the deletion query.
|
||
|
func (vdo *ValidatorsDeleteOne) Exec(ctx context.Context) error {
|
||
|
n, err := vdo.vd.Exec(ctx)
|
||
|
switch {
|
||
|
case err != nil:
|
||
|
return err
|
||
|
case n == 0:
|
||
|
return &NotFoundError{validators.Label}
|
||
|
default:
|
||
|
return nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ExecX is like Exec, but panics if an error occurs.
|
||
|
func (vdo *ValidatorsDeleteOne) ExecX(ctx context.Context) {
|
||
|
if err := vdo.Exec(ctx); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|