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