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