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