manager/ent/alias_delete.go

89 lines
2.2 KiB
Go
Raw Normal View History

2025-02-06 09:31:49 +01:00
// Code generated by ent, DO NOT EDIT.
2022-04-08 21:26:25 +02:00
package ent
import (
"context"
"code.icod.de/postfix/manager/ent/alias"
"code.icod.de/postfix/manager/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
)
// AliasDelete is the builder for deleting a Alias entity.
type AliasDelete struct {
config
hooks []Hook
mutation *AliasMutation
}
// Where appends a list predicates to the AliasDelete builder.
func (ad *AliasDelete) Where(ps ...predicate.Alias) *AliasDelete {
ad.mutation.Where(ps...)
return ad
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (ad *AliasDelete) Exec(ctx context.Context) (int, error) {
2025-02-06 09:31:49 +01:00
return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks)
2022-04-08 21:26:25 +02:00
}
// ExecX is like Exec, but panics if an error occurs.
func (ad *AliasDelete) ExecX(ctx context.Context) int {
n, err := ad.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (ad *AliasDelete) sqlExec(ctx context.Context) (int, error) {
2025-02-06 09:31:49 +01:00
_spec := sqlgraph.NewDeleteSpec(alias.Table, sqlgraph.NewFieldSpec(alias.FieldID, field.TypeInt64))
2022-04-08 21:26:25 +02:00
if ps := ad.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
2025-02-06 09:31:49 +01:00
affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
ad.mutation.done = true
return affected, err
2022-04-08 21:26:25 +02:00
}
// AliasDeleteOne is the builder for deleting a single Alias entity.
type AliasDeleteOne struct {
ad *AliasDelete
}
2025-02-06 09:31:49 +01:00
// Where appends a list predicates to the AliasDelete builder.
func (ado *AliasDeleteOne) Where(ps ...predicate.Alias) *AliasDeleteOne {
ado.ad.mutation.Where(ps...)
return ado
}
2022-04-08 21:26:25 +02:00
// Exec executes the deletion query.
func (ado *AliasDeleteOne) Exec(ctx context.Context) error {
n, err := ado.ad.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{alias.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (ado *AliasDeleteOne) ExecX(ctx context.Context) {
2025-02-06 09:31:49 +01:00
if err := ado.Exec(ctx); err != nil {
panic(err)
}
2022-04-08 21:26:25 +02:00
}