db

package
v0.0.0-...-db79cbe Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_LIMIT = 10
)

Variables

This section is empty.

Functions

func Paginate

func Paginate(page, limit string) func(db *gorm.DB) *gorm.DB

Paginate creates a GORM scope to paginate queries. TODO: Continue and Optimize

Types

type DB

type DB struct {
	*gorm.DB
}

DB represents the database.

func New

func New(config *DatabaseConfig) (*DB, error)

New makes the connection to the database.

func (*DB) MakeMigrations

func (db *DB) MakeMigrations()

MakeMigrations runs GORM migrations.

type DatabaseConfig

type DatabaseConfig struct {
	Driver          string // Not used
	Host            string
	Username        string
	Password        string
	Port            int
	Database        string
	Charset         string
	Collation       string
	Location        string
	MaxIdleConns    int           // Sets the maximum number of connections in the idle connection pool
	MaxOpenConns    int           // Sets the maximum number of open connections to the database
	ConnMaxLifetime time.Duration // Sets the maximum amount of time a connection may be reused
}

DatabaseConfig represents the database configuration.

Jump to

Keyboard shortcuts

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