89 lines
2.3 KiB
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"
|
|
"github.com/xmdhs/authlib-skin/db/ent/predicate"
|
|
"github.com/xmdhs/authlib-skin/db/ent/usertoken"
|
|
)
|
|
|
|
// UserTokenDelete is the builder for deleting a UserToken entity.
|
|
type UserTokenDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *UserTokenMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the UserTokenDelete builder.
|
|
func (utd *UserTokenDelete) Where(ps ...predicate.UserToken) *UserTokenDelete {
|
|
utd.mutation.Where(ps...)
|
|
return utd
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (utd *UserTokenDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, utd.sqlExec, utd.mutation, utd.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (utd *UserTokenDelete) ExecX(ctx context.Context) int {
|
|
n, err := utd.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (utd *UserTokenDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(usertoken.Table, sqlgraph.NewFieldSpec(usertoken.FieldID, field.TypeInt))
|
|
if ps := utd.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, utd.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
utd.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// UserTokenDeleteOne is the builder for deleting a single UserToken entity.
|
|
type UserTokenDeleteOne struct {
|
|
utd *UserTokenDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the UserTokenDelete builder.
|
|
func (utdo *UserTokenDeleteOne) Where(ps ...predicate.UserToken) *UserTokenDeleteOne {
|
|
utdo.utd.mutation.Where(ps...)
|
|
return utdo
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (utdo *UserTokenDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := utdo.utd.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{usertoken.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (utdo *UserTokenDeleteOne) ExecX(ctx context.Context) {
|
|
if err := utdo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|