// Code generated by ent, DO NOT EDIT. package ent import ( "context" "tss-rocks-be/ent/postcontent" "tss-rocks-be/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // PostContentDelete is the builder for deleting a PostContent entity. type PostContentDelete struct { config hooks []Hook mutation *PostContentMutation } // Where appends a list predicates to the PostContentDelete builder. func (pcd *PostContentDelete) Where(ps ...predicate.PostContent) *PostContentDelete { pcd.mutation.Where(ps...) return pcd } // Exec executes the deletion query and returns how many vertices were deleted. func (pcd *PostContentDelete) 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 *PostContentDelete) ExecX(ctx context.Context) int { n, err := pcd.Exec(ctx) if err != nil { panic(err) } return n } func (pcd *PostContentDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(postcontent.Table, sqlgraph.NewFieldSpec(postcontent.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 } // PostContentDeleteOne is the builder for deleting a single PostContent entity. type PostContentDeleteOne struct { pcd *PostContentDelete } // Where appends a list predicates to the PostContentDelete builder. func (pcdo *PostContentDeleteOne) Where(ps ...predicate.PostContent) *PostContentDeleteOne { pcdo.pcd.mutation.Where(ps...) return pcdo } // Exec executes the deletion query. func (pcdo *PostContentDeleteOne) Exec(ctx context.Context) error { n, err := pcdo.pcd.Exec(ctx) switch { case err != nil: return err case n == 0: return &NotFoundError{postcontent.Label} default: return nil } } // ExecX is like Exec, but panics if an error occurs. func (pcdo *PostContentDeleteOne) ExecX(ctx context.Context) { if err := pcdo.Exec(ctx); err != nil { panic(err) } }