csql

package
v0.0.0-...-5538d7f Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package csql helps create and manage database connections

Index

Constants

This section is empty.

Variables

WireModule can be used as part of google/wire setup.

Functions

func GetConn

func GetConn(ctx context.Context, db *gorm.DB) *gorm.DB

GetConn returns a db connection from the context or the given default connection if context is empty.

func NewDBConnection

func NewDBConnection(lc *copper.Lifecycle, appConfig cconfig.Config, logger clogger.Logger) (*gorm.DB, error)

NewDBConnection creates and returns a new database connection. The connection is closed when the app exits.

Types

type Migration

type Migration interface {
	Run() error
}

Migration can be implemented by any struct that runs a database migration

type Migrator

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

Migrator can run database migrations by running all of the provided migrations

func NewMigrator

func NewMigrator(p NewMigratorParams) *Migrator

NewMigrator creates a new Migrator

func (*Migrator) Run

func (m *Migrator) Run() error

Run runs all of the provided database migrations

type NewMigratorParams

type NewMigratorParams struct {
	Migrations []Migration
	Logger     clogger.Logger
}

NewMigratorParams holds the params needed for NewMigrator

Jump to

Keyboard shortcuts

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