func (s *Service) SetMetadata(ctx context.Context, key string, value []byte) error {
	tx := s.tx(ctx)
	if tx == nil {
		return ErrNoTransaction
	}
	_, err := tx.Exec(ctx, `
      INSERT INTO t_metadata(f_key
                            ,f_value)
      VALUES($1,$2)
      ON CONFLICT (f_key) DO
      UPDATE
      SET f_value = excluded.f_value`,
		key,
		value,
	)
	return err
}
SetMetadata sets a metadata key to a JSON value.
package postgresql
import (
	"context"
	"github.com/jackc/pgtype"
	"github.com/jackc/pgx/v4"
	"github.com/pkg/errors"
)