query

package
v0.439.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec[Req any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) error

func Many

func Many[Req, Resp any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) ([]Resp, error)

func One

func One[Req, Resp any](ctx context.Context, dbName string, rawSQL string, params []any, colFieldNames []tuple.Pair[string, string]) (resp Resp, err error)

Types

type Config

type Config struct {
	DSN      string
	Engine   string
	Endpoint *url.URL
}

func (*Config) Validate

func (c *Config) Validate() error

type DB

type DB interface {
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

DB represents a database that can execute queries

type MultiService

type MultiService struct {
	// contains filtered or unexported fields
}

MultiService handles multiple database instances

func NewMultiService

func NewMultiService() *MultiService

func (*MultiService) AddService

func (m *MultiService) AddService(module string, name string, svc *Service) error

func (*MultiService) Close

func (m *MultiService) Close() error

func (*MultiService) GetService

func (m *MultiService) GetService(ref schema.RefKey) (*Service, bool)

func (*MultiService) GetServices

func (m *MultiService) GetServices() map[schema.RefKey]*Service

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, config Config) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Ping

func (*Service) SetEndpoint

func (s *Service) SetEndpoint(endpoint *url.URL)

SetEndpoint sets the endpoint after the server is confirmed ready

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL