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