// Code generated by ent, DO NOT EDIT. package ent import ( "context" "schisandra-album-cloud-microservices/common/ent/predicate" "schisandra-album-cloud-microservices/common/ent/scaauthrole" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // ScaAuthRoleDelete is the builder for deleting a ScaAuthRole entity. type ScaAuthRoleDelete struct { config hooks []Hook mutation *ScaAuthRoleMutation } // Where appends a list predicates to the ScaAuthRoleDelete builder. func (sard *ScaAuthRoleDelete) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDelete { sard.mutation.Where(ps...) return sard } // Exec executes the deletion query and returns how many vertices were deleted. func (sard *ScaAuthRoleDelete) Exec(ctx context.Context) (int, error) { return withHooks(ctx, sard.sqlExec, sard.mutation, sard.hooks) } // ExecX is like Exec, but panics if an error occurs. func (sard *ScaAuthRoleDelete) ExecX(ctx context.Context) int { n, err := sard.Exec(ctx) if err != nil { panic(err) } return n } func (sard *ScaAuthRoleDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(scaauthrole.Table, sqlgraph.NewFieldSpec(scaauthrole.FieldID, field.TypeInt64)) if ps := sard.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } affected, err := sqlgraph.DeleteNodes(ctx, sard.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } sard.mutation.done = true return affected, err } // ScaAuthRoleDeleteOne is the builder for deleting a single ScaAuthRole entity. type ScaAuthRoleDeleteOne struct { sard *ScaAuthRoleDelete } // Where appends a list predicates to the ScaAuthRoleDelete builder. func (sardo *ScaAuthRoleDeleteOne) Where(ps ...predicate.ScaAuthRole) *ScaAuthRoleDeleteOne { sardo.sard.mutation.Where(ps...) return sardo } // Exec executes the deletion query. func (sardo *ScaAuthRoleDeleteOne) Exec(ctx context.Context) error { n, err := sardo.sard.Exec(ctx) switch { case err != nil: return err case n == 0: return &NotFoundError{scaauthrole.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. func (sardo *ScaAuthRoleDeleteOne) ExecX(ctx context.Context) { if err := sardo.Exec(ctx); err != nil { panic(err) } }