database

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package database provides explicit SQL, GORM, and sqlx connectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Dialect store data used by this type.
	Dialect Dialect
	// DSN store data used by this type.
	DSN string
	// ORM store data used by this type.
	ORM ORM
	// MaxOpenConns store data used by this type.
	MaxOpenConns int
	// MaxIdleConns store data used by this type.
	MaxIdleConns int
	// ConnMaxLifetime store data used by this type.
	ConnMaxLifetime time.Duration
	// PingTimeout store data used by this type.
	PingTimeout time.Duration
}

Config defines an implementation type used by this package.

type Connection

type Connection struct {
	// SQL store data used by this type.
	SQL *sql.DB
	// GORM store data used by this type.
	GORM *gorm.DB
	// SQLX store data used by this type.
	SQLX *sqlx.DB
}

Connection defines an implementation type used by this package.

func Open

func Open(ctx context.Context, config Config) (*Connection, error)

Open performs this package operation.

func (*Connection) Close

func (c *Connection) Close() error

Close performs this package operation.

type Dialect

type Dialect string

Dialect defines an implementation type used by this package.

const (
	// MySQL define package-level implementation state.
	MySQL Dialect = "mysql"
	// MariaDB define package-level implementation state.
	MariaDB Dialect = "mariadb"
	// Postgres define package-level implementation state.
	Postgres Dialect = "postgres"
	// SQLite define package-level implementation state.
	SQLite Dialect = "sqlite"
)

type ORM

type ORM string

ORM defines an implementation type used by this package.

const (
	// ORMNone define package-level implementation state.
	ORMNone ORM = "none"
	// GORM define package-level implementation state.
	GORM ORM = "gorm"
	// SQLX define package-level implementation state.
	SQLX ORM = "sqlx"
)

Jump to

Keyboard shortcuts

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