database

package module
v0.0.0-...-d56f406 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 6 Imported by: 3

README

Openware package for database interactions

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(cnf *Config) error

Create the database MySQL/SQLite by name with existing connection

func Drop

func Drop(cnf *Config) error

Drop the database MySQL/SQLite with given db context

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"`
	Schema string `yaml:"schema" env:"DATABASE_SCHEMA" env-description:"Database schema name"`
}

Config for database connection TODO Set all default values

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