1
0
api/ent/ue_delete.go
2024-04-06 03:58:54 +09:00

89 lines
2.0 KiB
Go

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