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/gitcommit"
|
|
"registry-backend/ent/predicate"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// GitCommitDelete is the builder for deleting a GitCommit entity.
|
|
type GitCommitDelete struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *GitCommitMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the GitCommitDelete builder.
|
|
func (gcd *GitCommitDelete) Where(ps ...predicate.GitCommit) *GitCommitDelete {
|
|
gcd.mutation.Where(ps...)
|
|
return gcd
|
|
}
|
|
|
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
|
func (gcd *GitCommitDelete) Exec(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, gcd.sqlExec, gcd.mutation, gcd.hooks)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (gcd *GitCommitDelete) ExecX(ctx context.Context) int {
|
|
n, err := gcd.Exec(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (gcd *GitCommitDelete) sqlExec(ctx context.Context) (int, error) {
|
|
_spec := sqlgraph.NewDeleteSpec(gitcommit.Table, sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID))
|
|
if ps := gcd.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
affected, err := sqlgraph.DeleteNodes(ctx, gcd.driver, _spec)
|
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
gcd.mutation.done = true
|
|
return affected, err
|
|
}
|
|
|
|
// GitCommitDeleteOne is the builder for deleting a single GitCommit entity.
|
|
type GitCommitDeleteOne struct {
|
|
gcd *GitCommitDelete
|
|
}
|
|
|
|
// Where appends a list predicates to the GitCommitDelete builder.
|
|
func (gcdo *GitCommitDeleteOne) Where(ps ...predicate.GitCommit) *GitCommitDeleteOne {
|
|
gcdo.gcd.mutation.Where(ps...)
|
|
return gcdo
|
|
}
|
|
|
|
// Exec executes the deletion query.
|
|
func (gcdo *GitCommitDeleteOne) Exec(ctx context.Context) error {
|
|
n, err := gcdo.gcd.Exec(ctx)
|
|
switch {
|
|
case err != nil:
|
|
return err
|
|
case n == 0:
|
|
return &NotFoundError{gitcommit.Label}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (gcdo *GitCommitDeleteOne) ExecX(ctx context.Context) {
|
|
if err := gcdo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|