models

package
v0.0.0-...-3f65eb9 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: MIT Imports: 7 Imported by: 0

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        uint64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
	Name      string `sql:"type:varchar(30)"`
}

Jump to

Keyboard shortcuts

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