sql

package
v1.25.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 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, preparedStatementsEnabled bool) 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) Drop added in v1.20.0

func (m *Migrator) Drop() error

Drop 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