Files
registry-backend/ent/publisherpermission_delete.go

89 lines
2.5 KiB
Go

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