Help us shape the future of Go! Take the 2026 Go Developer Survey

gormdb

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultJournalMode                 = database.JournalModeWAL
	DefaultTimeout                     = 3 * time.Second
	DefaultSyncMode                    = database.SyncModeNORMAL
	DefaultForeignKeyConstraintsEnable = true
)

Functions

func New

func New(dbPath string, opts ...database.Option) (*gorm.DB, error)

func NewPostgres added in v0.2.3

func NewPostgres(connURL string, schema string, opts *PostgresOptions) (*gorm.DB, error)

NewPostgres creates a new GORM PostgreSQL connection. The connURL should be a PostgreSQL connection string in the format: postgres://user:password@host:port/dbname?sslmode=disable If schema is provided, a separate PostgreSQL schema will be created and used.

Types

type PostgresOptions added in v0.2.3

type PostgresOptions struct {
	// MaxOpenConns is the maximum number of open connections to the database.
	MaxOpenConns int
	// MaxIdleConns is the maximum number of idle connections in the pool.
	MaxIdleConns int
	// ConnMaxLifetime is the maximum amount of time a connection may be reused.
	ConnMaxLifetime time.Duration
}

PostgresOptions configures a GORM PostgreSQL connection.

func PostgresOptionsFromConfig added in v0.2.3

func PostgresOptionsFromConfig(cfg app.PostgresConfig) *PostgresOptions

PostgresOptionsFromConfig creates PostgresOptions from app.PoolConfig. Uses conservative defaults for any zero values.

Jump to

Keyboard shortcuts

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