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