mirror of
https://github.com/hanzoui/registry-backend.git
synced 2026-10-30 20:30:45 +00:00
89 lines
2.3 KiB
Go
89 lines
2.3 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"registry-backend/ent/nodeversion"
|
|
"registry-backend/ent/predicate"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// NodeVersionDelete is the builder for deleting a NodeVersion entity.
|
|
type NodeVersionDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *NodeVersionMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the NodeVersionDelete builder.
|
|
func (nvd *NodeVersionDelete) Where(ps ...predicate.NodeVersion) *NodeVersionDelete {
|
|
nvd.mutation.Where(ps...)
|
|
return nvd
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (nvd *NodeVersionDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, nvd.sqlExec, nvd.mutation, nvd.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (nvd *NodeVersionDelete) ExecX(ctx context.Context) int {
|
|
n, err := nvd.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (nvd *NodeVersionDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(nodeversion.Table, sqlgraph.NewFieldSpec(nodeversion.FieldID, field.TypeUUID))
|
|
if ps := nvd.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, nvd.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
nvd.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// NodeVersionDeleteOne is the builder for deleting a single NodeVersion entity.
|
|
type NodeVersionDeleteOne struct {
|
|
nvd *NodeVersionDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the NodeVersionDelete builder.
|
|
func (nvdo *NodeVersionDeleteOne) Where(ps ...predicate.NodeVersion) *NodeVersionDeleteOne {
|
|
nvdo.nvd.mutation.Where(ps...)
|
|
return nvdo
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (nvdo *NodeVersionDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := nvdo.nvd.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{nodeversion.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (nvdo *NodeVersionDeleteOne) ExecX(ctx context.Context) {
|
|
if err := nvdo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|