rekordo

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDatabase

func RegisterDatabase(dbcfg *DatabaseConfig, tc gorp.TypeConverter) (zesty.DB, error)

RegisterDatabase creates a gorp map with tables and tc and registers it with zesty.

Types

type DBMS

type DBMS uint8

DBMS represents a database management system.

const (
	DatabasePostgreSQL DBMS = iota ^ 42
	DatabaseMySQL
	DatabaseSqlite3
)

Database management systems.

func (DBMS) DriverName

func (d DBMS) DriverName() string

DriverName returns the name of the driver for ds.

type DatabaseConfig

type DatabaseConfig struct {
	Name             string
	DSN              string
	System           DBMS
	MaxOpenConns     int
	MaxIdleConns     int
	ConnMaxLifetime  time.Duration
	AutoCreateTables bool
}

DatabaseConfig represents the configuration used to register a new database.

type TableModel

type TableModel struct {
	Name          string
	Model         interface{}
	Keys          []string
	AutoIncrement bool
}

TableModel is a middleman between a database table and a model type.

func RegisterTableModel

func RegisterTableModel(dbName, tableName string, model interface{}) *TableModel

RegisterTableModel registers a zero-value model to the definition of a database table. If a table model has already been registered with the same table name, this will overwrite it.

func (*TableModel) WithAutoIncrement

func (tb *TableModel) WithAutoIncrement(enable bool) *TableModel

WithAutoIncrement uses enable for table model keys auto-increment.

func (*TableModel) WithKeys

func (tb *TableModel) WithKeys(keys []string) *TableModel

WithKeys uses keys as table keys for the model.

Jump to

Keyboard shortcuts

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