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