database

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(cnf *Config) (*gorm.DB, error)

Connect to database MySQL/SQLite using gorm gorm (GO ORM for SQL): http://gorm.io/docs/connecting_to_the_database.html TODO Switch to Config struct

func Create

func Create(db *gorm.DB, dbName string) error

Create the database MySQL/SQLite by name with existing connection TODO read dbName from gorm config FIXME it doesn't work with SQlite

func Drop

func Drop(db *gorm.DB, dbName string) error

FIXME it doesn't work with SQlite

Types

type Config

type Config struct {
	Driver string `yaml:"driver" env:"DATABASE_DRIVER" env-description:"Database driver"`
	Host   string `yaml:"host" env:"DATABASE_HOST" env-description:"Database host"`
	Port   string `yaml:"port" env:"DATABASE_PORT" env-description:"Database port"`
	Name   string `yaml:"name" env:"DATABASE_NAME" env-description:"Database name"`
	User   string `yaml:"user" env:"DATABASE_USER" env-description:"Database user"`
	Pass   string `env:"DATABASE_PASS" env-description:"Database user password"`
	Pool   int    `yaml:"pool" env:"DATABASE_POOL" env-description:"Database pool size"`
}

type Timestamps

type Timestamps struct {
	CreatedAt time.Time `yaml:"created_at"`
	UpdatedAt time.Time `yaml:"updated_at"`
}

Timestamps adding time at the end of models

Jump to

Keyboard shortcuts

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