provider

package
v0.0.0-...-a17827a Latest Latest
Warning

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

Go to latest
Published: May 14, 2017 License: GPL-3.0 Imports: 4 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeDatabase

func InitializeDatabase(p *RootProvider)

InitializeDatabase define the user table properties

Types

type DatabaseType

type DatabaseType int

DatabaseType represent a database type

const (
	// Unknown represent a non-handled database
	Unknown DatabaseType = iota
	// SQLite represent a SQLite database
	SQLite
	// MySQL represent a MySQL database
	MySQL
)

type DefaultConfig

type DefaultConfig struct {
	CreateTablesIfNotExists bool `json:"-"`
	DropTablesIfExists      bool `json:"-"`
}

DefaultConfig is the configuration needed for running every database

type MySQLConfig

type MySQLConfig struct {
	DefaultConfig
	Username string `json:"username"`
	Password string `json:"password"`
	Address  string `json:"address"`
	Database string `json:"database"`
}

MySQLConfig is the configuration needed for running an MySQL database

type RootProvider

type RootProvider struct {
	Type   DatabaseType
	DB     *gorm.DB
	Config interface{}
}

RootProvider contains all the methods and properties needed to manage a database

var (
	// RP is the selected database
	RP *RootProvider
	// ErrRPIsNil is the error throwed when RP is nil
	ErrRPIsNil = errors.New("database is nil")
)

type SQLiteConfig

type SQLiteConfig struct {
	DefaultConfig
	Filepath string `json:"file" validate:"file=omitempty+readable:createifmissing"`
}

SQLiteConfig is the configuration needed for running an SQLite database

type TablesManagement

type TablesManagement interface {
	CreateTables() (err error)
	DropTables() (err error)
	CreateIndexes() (err error)
}

TablesManagement contains all the required tables needed to manage tables

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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