gormkitteh

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

TODO: Make public?

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDSN  = errors.New("invalid DSN")
	ErrUnknownType = errors.New("unknown DSN type")
)

Functions

func Open

func Open(cfg *Config, f func(*gorm.Config)) (*gorm.DB, error)

Open a DB according to given configuration. Open calls cfg.Explicit() is called before evaluating it.

func OpenZ

func OpenZ(z *zap.Logger, cfg *Config, f func(*gorm.Config)) (*gorm.DB, error)

Types

type Config

type Config struct {
	// If `Type` is empty, `DSN` must be in the form of "type:actual_dsn".
	// If both `Type` and `DSN` are empty, `Type` will be considered "sqlite"
	// with an empty DSN, which will make sqlite use a temporary database
	// (see https://www.sqlite.org/inmemorydb.html).
	Type  string `koanf:"type"`
	DSN   string `koanf:"dsn"`
	Debug bool   `koanf:"debug"`

	SlowQueryThreshold time.Duration `koanf:"slow_query_threshold"`
}

func (Config) Explicit

func (c Config) Explicit() (*Config, error)

Jump to

Keyboard shortcuts

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