Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	*gorm.DB
	// contains filtered or unexported fields
}

Model facilitate database interactions

func NewModel

func NewModel() *Model

NewModel returns a new Model without opening database connection

func (*Model) AutoDropAll

func (m *Model) AutoDropAll()

AutoDropAll drops all tables of all registered models

func (*Model) AutoMigrateAll

func (m *Model) AutoMigrateAll()

AutoMigrateAll runs migrations for all the registered models

func (*Model) IsOpen

func (m *Model) IsOpen() bool

IsOpen returns true if the Model has already established connection to the database

func (*Model) OpenWithConfig

func (m *Model) OpenWithConfig(cfg *config.Configuration) error

OpenWithConfig opens database connection with the settings found in cfg

func (*Model) Register

func (m *Model) Register(values ...interface{}) error

Register adds the values to the models registry

type User

type User struct {
	ID        string `gorm:"type:uuid;primary_key;default:gen_random_uuid()"`
	Name      string `sql:"type:varchar(30)"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

Source Files