sql

package
v1.19.5 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuilderFor added in v1.14.0

func BuilderFor(db *sql.DB, driver Driver) sq.StatementBuilderType

BuilderFor returns a squirrel statement builder which decorates the provided sql.DB configured for the provided driver.

func WithMigrate added in v1.14.0

func WithMigrate(o *Options)

func WithSSLDisabled added in v1.14.0

func WithSSLDisabled(o *Options)

Types

type Driver

type Driver uint8

Driver represents a database driver

const (

	// SQLite ...
	SQLite Driver
	// Postgres ...
	Postgres
	// MySQL ...
	MySQL
	// CockroachDB ...
	CockroachDB
)

func Open

func Open(cfg config.Config, opts ...Option) (*sql.DB, Driver, error)

Open opens a connection to the db

func (Driver) AdaptError added in v1.15.0

func (d Driver) AdaptError(err error) error

AdaptError converts specific known-driver errors into wrapped storage errors.

func (Driver) String

func (d Driver) String() string

type JSONField added in v1.15.0

type JSONField[T any] struct {
	T T
}

func (*JSONField[T]) Scan added in v1.15.0

func (f *JSONField[T]) Scan(v any) error

func (*JSONField[T]) Value added in v1.15.0

func (f *JSONField[T]) Value() (driver.Value, error)

type Migrator

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

Migrator is responsible for migrating the database schema

func NewMigrator

func NewMigrator(cfg config.Config, logger *zap.Logger) (*Migrator, error)

NewMigrator creates a new Migrator

func (*Migrator) Close

func (m *Migrator) Close() (source, db error)

Close closes the source and db

func (*Migrator) Down added in v1.15.0

func (m *Migrator) Down() error

Down returns the down migrations (drops the database)

func (*Migrator) Up added in v1.15.0

func (m *Migrator) Up(force bool) error

Up runs any pending migrations

type NullableTimestamp added in v1.15.0

type NullableTimestamp Timestamp

func (*NullableTimestamp) Scan added in v1.15.0

func (t *NullableTimestamp) Scan(value interface{}) error

func (*NullableTimestamp) Value added in v1.15.0

func (t *NullableTimestamp) Value() (driver.Value, error)

type Option added in v1.14.0

type Option func(*Options)

type Options added in v1.14.0

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

type Timestamp added in v1.15.0

type Timestamp struct {
	*timestamppb.Timestamp
}

func (*Timestamp) Scan added in v1.15.0

func (t *Timestamp) Scan(value interface{}) error

func (*Timestamp) Value added in v1.15.0

func (t *Timestamp) Value() (driver.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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