ALHP.GO/ent/dbpackage_delete.go
anonfunc fa902fa68c Git-based package source layout (#193)
Co-authored-by: Giovanni Harting <539@idlegandalf.com>
Reviewed-on: #193
2023-05-21 20:28:23 +02: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"
"somegit.dev/ALHP/ALHP.GO/ent/dbpackage"
"somegit.dev/ALHP/ALHP.GO/ent/predicate"
)
// DBPackageDelete is the builder for deleting a DBPackage entity.
type DBPackageDelete struct {
config
hooks []Hook
mutation *DBPackageMutation
}
// Where appends a list predicates to the DBPackageDelete builder.
func (dpd *DBPackageDelete) Where(ps ...predicate.DBPackage) *DBPackageDelete {
dpd.mutation.Where(ps...)
return dpd
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (dpd *DBPackageDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, dpd.sqlExec, dpd.mutation, dpd.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (dpd *DBPackageDelete) ExecX(ctx context.Context) int {
n, err := dpd.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (dpd *DBPackageDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(dbpackage.Table, sqlgraph.NewFieldSpec(dbpackage.FieldID, field.TypeInt))
if ps := dpd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, dpd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
dpd.mutation.done = true
return affected, err
}
// DBPackageDeleteOne is the builder for deleting a single DBPackage entity.
type DBPackageDeleteOne struct {
dpd *DBPackageDelete
}
// Where appends a list predicates to the DBPackageDelete builder.
func (dpdo *DBPackageDeleteOne) Where(ps ...predicate.DBPackage) *DBPackageDeleteOne {
dpdo.dpd.mutation.Where(ps...)
return dpdo
}
// Exec executes the deletion query.
func (dpdo *DBPackageDeleteOne) Exec(ctx context.Context) error {
n, err := dpdo.dpd.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{dbpackage.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (dpdo *DBPackageDeleteOne) ExecX(ctx context.Context) {
if err := dpdo.Exec(ctx); err != nil {
panic(err)
}
}