rekordo

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDatabase

func RegisterDatabase(db *DatabaseConfig, tc gorp.TypeConverter, dialect gorp.Dialect) 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
	AutoCreateTables bool
	ConnMaxLifetime  time.Duration
	ConnMaxIdleTime  time.Duration
}

DatabaseConfig represents the configuration used to register a new database.

type TableModel

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

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.

func (*TableModel) WithSchema

func (tb *TableModel) WithSchema(schema string) *TableModel

WithSchema specifies the table exists within a schema

Jump to

Keyboard shortcuts

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