TinySkin/db/ent/usertexture_delete.go
thehrz 0b880bece8
All checks were successful
CI / deploy (push) Successful in 57s
pref: rename project
2025-01-24 17:12:15 +08:00

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"
"tinyskin/db/ent/predicate"
"tinyskin/db/ent/usertexture"
)
// UserTextureDelete is the builder for deleting a UserTexture entity.
type UserTextureDelete struct {
config
hooks []Hook
mutation *UserTextureMutation
}
// Where appends a list predicates to the UserTextureDelete builder.
func (utd *UserTextureDelete) Where(ps ...predicate.UserTexture) *UserTextureDelete {
utd.mutation.Where(ps...)
return utd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (utd *UserTextureDelete) 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 *UserTextureDelete) ExecX(ctx context.Context) int {
n, err := utd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (utd *UserTextureDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(usertexture.Table, sqlgraph.NewFieldSpec(usertexture.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
}
// UserTextureDeleteOne is the builder for deleting a single UserTexture entity.
type UserTextureDeleteOne struct {
utd *UserTextureDelete
}
// Where appends a list predicates to the UserTextureDelete builder.
func (utdo *UserTextureDeleteOne) Where(ps ...predicate.UserTexture) *UserTextureDeleteOne {
utdo.utd.mutation.Where(ps...)
return utdo
}
// Exec executes the deletion query.
func (utdo *UserTextureDeleteOne) Exec(ctx context.Context) error {
n, err := utdo.utd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{usertexture.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (utdo *UserTextureDeleteOne) ExecX(ctx context.Context) {
if err := utdo.Exec(ctx); err != nil {
panic(err)
}
}