rano/db/ent/verifytoken_delete.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"
"gitserver.in/patialtech/rano/db/ent/predicate"
"gitserver.in/patialtech/rano/db/ent/verifytoken"
)
// VerifyTokenDelete is the builder for deleting a VerifyToken entity.
type VerifyTokenDelete struct {
config
hooks []Hook
mutation *VerifyTokenMutation
}
// Where appends a list predicates to the VerifyTokenDelete builder.
func (vtd *VerifyTokenDelete) Where(ps ...predicate.VerifyToken) *VerifyTokenDelete {
vtd.mutation.Where(ps...)
return vtd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (vtd *VerifyTokenDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, vtd.sqlExec, vtd.mutation, vtd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (vtd *VerifyTokenDelete) ExecX(ctx context.Context) int {
n, err := vtd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (vtd *VerifyTokenDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(verifytoken.Table, sqlgraph.NewFieldSpec(verifytoken.FieldID, field.TypeInt64))
if ps := vtd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, vtd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
vtd.mutation.done = true
return affected, err
}
// VerifyTokenDeleteOne is the builder for deleting a single VerifyToken entity.
type VerifyTokenDeleteOne struct {
vtd *VerifyTokenDelete
}
// Where appends a list predicates to the VerifyTokenDelete builder.
func (vtdo *VerifyTokenDeleteOne) Where(ps ...predicate.VerifyToken) *VerifyTokenDeleteOne {
vtdo.vtd.mutation.Where(ps...)
return vtdo
}
// Exec executes the deletion query.
func (vtdo *VerifyTokenDeleteOne) Exec(ctx context.Context) error {
n, err := vtdo.vtd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{verifytoken.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (vtdo *VerifyTokenDeleteOne) ExecX(ctx context.Context) {
if err := vtdo.Exec(ctx); err != nil {
panic(err)
}
}