Files
mtusi2026lab7/service/internal/pkg/postgres/after-connect.go
T
2026-11-18 11:36:21 +03:00

26 lines
543 B
Go

package postgres
import (
"context"
"github.com/jackc/pgx/v5"
pgxUUID "github.com/vgarvardt/pgx-google-uuid/v5"
)
type AfterConnect func(ctx context.Context, conn *pgx.Conn) error
func AddUUIDSupport(_ context.Context, conn *pgx.Conn) error {
pgxUUID.Register(conn.TypeMap())
return nil
}
func WithEnumTypeSupport(enumName string) AfterConnect {
return func(ctx context.Context, conn *pgx.Conn) error {
dt, err := conn.LoadType(ctx, enumName)
if err != nil {
return err
}
conn.TypeMap().RegisterType(dt)
return nil
}
}