db

package
v0.1.1-beta Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB is a global variable for database

Functions

func New

func New(dbEngine string, dsn string)

New initiates new database connection based on submitted database engine

func NewMysql

func NewMysql(dsn string, dbconf *gorm.Config) (*gorm.DB, error)

NewMysql returns database object using mysql as database engine

func NewPostgresql

func NewPostgresql(dsn string, dbconf *gorm.Config) (*gorm.DB, error)

NewPostgresql returns database object using postgres as database engine

func SetVerbose

func SetVerbose(verbose bool)

SetVerbose sets verbose mode on database query

Types

type Model

type Model struct {
	ID        uuid.UUID `gorm:"column:_id;type:uuid;not null;unique;primaryKey;index;"`
	CreatedAt time.Time `gorm:"default:now()"`
	UpdatedAt *time.Time
	DeletedAt *time.Time
}

Model is the default schema for database module This should be include in all schema model

func (*Model) GenerateID

func (m *Model) GenerateID()

GenerateID will generate a random UUID and set it into the ID

Jump to

Keyboard shortcuts

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