rano/db/ent/accesscontrol_delete.go
2024-11-10 14:52:33 +05:30

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