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