dialector

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDriverNotFound = errors.New("driver not found")

Functions

This section is empty.

Types

type Config

type Config struct {
	Host     string
	Port     int
	Database string
	Username string
	Password string
	Params   string

	// DSN will override all above configs
	// Example:
	//  - Mysql: "user1@tcp(127.0.0.1:3306)/demo"
	// 	- Postgres: "host=127.0.0.1 user=user1 password=secret1 dbname=demo port=5432"
	//  - Sqlite:
	// 		- "sqlite.db"
	//  	- "file::memory:?cache=shared"
	Dsn string
}

type Mysql

type Mysql struct {
}

func (Mysql) Driver

func (m Mysql) Driver() string

func (Mysql) Open

func (m Mysql) Open(cf *Config) (gorm.Dialector, error)

type Postgres

type Postgres struct {
}

func (Postgres) Driver

func (p Postgres) Driver() string

func (Postgres) Open

func (p Postgres) Open(cf *Config) (gorm.Dialector, error)

type Resolver

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

func NewResolver

func NewResolver(strategies []Strategy) *Resolver

func (Resolver) Resolve

func (r Resolver) Resolve(driver string) (Strategy, error)

type Sqlite

type Sqlite struct {
}

func (Sqlite) Driver

func (m Sqlite) Driver() string

func (Sqlite) Open

func (m Sqlite) Open(cf *Config) (gorm.Dialector, error)

type Strategy

type Strategy interface {
	Driver() string

	Open(cf *Config) (gorm.Dialector, error)
}

func NewMysql

func NewMysql() Strategy

func NewPostgres

func NewPostgres() Strategy

func NewSqlite

func NewSqlite() Strategy

Jump to

Keyboard shortcuts

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