func (s *Store) DeleteTx(ctx context.Context, tx *sql.Tx, ids ...string) error {
	err := permission.LimitCheckAny(ctx, permission.User, permission.Admin)
	if err != nil {
		return err
	}
	err = validate.ManyUUID("MonitorID", ids, 100)
	if err != nil {
		return err
	}
	stmt := s.delete
	if tx != nil {
		stmt = tx.StmtContext(ctx, stmt)
	}
	_, err = stmt.ExecContext(ctx, sqlutil.UUIDArray(ids))
	return err
}
DeleteTx deletes the heartbeat check with the given ID(s).
package heartbeat
import (
	"context"
	"database/sql"
	"github.com/google/uuid"
	"github.com/jackc/pgtype"
	"github.com/target/goalert/permission"
	"github.com/target/goalert/search"
	"github.com/target/goalert/util"
	"github.com/target/goalert/util/sqlutil"
	"github.com/target/goalert/validation/validate"
)
type Store struct {
	db *sql.DB
	create     *sql.Stmt
	findAll    *sql.Stmt
	findMany   *sql.Stmt
	delete     *sql.Stmt
	update     *sql.Stmt
	getSvcID   *sql.Stmt
	findOneUpd *sql.Stmt
	heartbeat  *sql.Stmt
}
func NewStore(ctx context.Context, db *sql.DB) (*Store, error) {
	p := &util.Prepare{DB: db, Ctx: ctx}
	return &Store{
		db: db,
		create: p.P(`
			insert into heartbeat_monitors (
				id, name, service_id, heartbeat_interval
			) values ($1, $2, $3, $4)
		`),
		findAll: p.P(`
			select
				id, name, service_id, heartbeat_interval, last_state, last_heartbeat
			from heartbeat_monitors
			where service_id = $1
		`),
		findMany: p.P(`
			select
				id, name, service_id, heartbeat_interval, last_state, last_heartbeat
			from heartbeat_monitors
			where id = any($1)
		`),
		findOneUpd: p.P(`
			select
				id, name, service_id, heartbeat_interval, last_state, last_heartbeat
			from heartbeat_monitors
			where id = $1
			for update
		`),
		delete: p.P(`
			delete from heartbeat_monitors
			where id = any($1)
		`),
		update: p.P(`
			update heartbeat_monitors
			set
				name = $2,
				heartbeat_interval = $3
			where id = $1
		`),
		getSvcID: p.P(`select service_id from heartbeat_monitors where id = $1`),
		heartbeat: p.P(`
			update heartbeat_monitors
			set last_heartbeat = now()
			where id = $1
		`),
	}, p.Err
}
func (s *Store) CreateTx(ctx context.Context, tx *sql.Tx, m *Monitor) (*Monitor, error) {
	err := permission.LimitCheckAny(ctx, permission.User, permission.Admin)
	if err != nil {
		return nil, err
	}
	n, err := m.Normalize()
	if err != nil {
		return nil, err
	}
	var timeout pgtype.Interval
	if err = timeout.Set(n.Timeout); err != nil {
		return nil, err
	}
	n.ID = uuid.New().String()
	n.lastState = StateInactive
	_, err = tx.StmtContext(ctx, s.create).ExecContext(ctx, n.ID, n.Name, n.ServiceID, &timeout)
	if err != nil {
		return nil, err
	}
	return n, nil
}
func (s *Store) RecordHeartbeat(ctx context.Context, id string) error {
	err := validate.UUID("MonitorID", id)
	if err != nil {
		return err
	}
	_, err = s.heartbeat.ExecContext(ctx, id)
	return err
}