Files
polaris/ent/importlist_delete.go
2024-09-02 23:47:19 +08:00

89 lines
2.3 KiB
Go

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