typdb

package
v0.9.17 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEnvKeys = &EnvKeys{
	DBName: "DBNAME",
	DBUser: "DBUSER",
	DBPass: "DBPASS",
	Host:   "HOST",
	Port:   "PORT",
}

Functions

This section is empty.

Types

type Config

type Config struct {
	DBName string
	DBUser string
	DBPass string
	Host   string
	Port   string
}

type DBConn

type DBConn interface {
	Connect(*Config) (*sql.DB, error)
	ConnectAdmin(*Config) (*sql.DB, error)
	Migrate(src string, cfg *Config) (*migrate.Migrate, error)
}

type DBRepoAnnot

type DBRepoAnnot struct {
	TagName string // By default is @dbrepo
}

DBRepoAnnot ...

func (*DBRepoAnnot) Annotate

func (m *DBRepoAnnot) Annotate() typast.Processor

Annotate Envconfig to prepare dependency-injection and env-file

func (*DBRepoAnnot) GetDest

func (*DBRepoAnnot) GetDest(file string) string

GetDest get destination

func (*DBRepoAnnot) Process

func (m *DBRepoAnnot) Process(c *typgo.Context, directive typast.Directives) error

type DBTool

type DBTool struct {
	DBConn
	Name         string
	EnvKeys      *EnvKeys
	MigrationSrc string
	SeedSrc      string
	CreateFormat string
	DropFormat   string
}

func (*DBTool) CreateDB

func (t *DBTool) CreateDB(c *typgo.Context) error

CreateDB create database

func (*DBTool) DropDB

func (t *DBTool) DropDB(c *typgo.Context) error

DropDB delete database

func (*DBTool) MigrateDB

func (t *DBTool) MigrateDB(c *typgo.Context) error

MigrateDB migrate database

func (*DBTool) MigrationFile

func (t *DBTool) MigrationFile(c *typgo.Context) error

MigrationFile seed database

func (*DBTool) RollbackDB

func (t *DBTool) RollbackDB(c *typgo.Context) error

RollbackDB rollback database

func (*DBTool) SeedDB

func (t *DBTool) SeedDB(c *typgo.Context) error

SeedDB seed database

func (*DBTool) Task

func (t *DBTool) Task() *typgo.Task

Task for postgres

type EntityTmplData

type EntityTmplData struct {
	typast.Signature
	Name       string
	Table      string
	Dialect    string
	CtorDB     string
	Pkg        string
	SourcePkg  string
	Dest       string
	Fields     []*Field
	Imports    map[string]string
	PrimaryKey *Field
}

EntityTmplData ...

type EnvKeys

type EnvKeys Config

func EnvKeysWithPrefix

func EnvKeysWithPrefix(prefix string) *EnvKeys

func (*EnvKeys) Config

func (e *EnvKeys) Config() *Config

type Field

type Field struct {
	Name         string
	Type         string
	Column       string
	PrimaryKey   bool
	DefaultValue string
	SkipUpdate   bool
}

Field repo

type MySQL

type MySQL struct {
	Name         string
	EnvKeys      *EnvKeys
	MigrationSrc string
	SeedSrc      string
	DockerName   string
}

MySQL for postgres

func (*MySQL) Console

func (t *MySQL) Console(c *typgo.Context) error

Console interactice for postgres

func (*MySQL) DBTool

func (t *MySQL) DBTool() *DBTool

func (*MySQL) Task

func (t *MySQL) Task() *typgo.Task

Task for postgress

type MySQLConn

type MySQLConn struct{}

func (MySQLConn) Connect

func (MySQLConn) Connect(c *Config) (*sql.DB, error)

func (MySQLConn) ConnectAdmin

func (MySQLConn) ConnectAdmin(c *Config) (*sql.DB, error)

func (MySQLConn) Migrate

func (m MySQLConn) Migrate(src string, cfg *Config) (*migrate.Migrate, error)

type PGConn

type PGConn struct{}

func (PGConn) Connect

func (PGConn) Connect(c *Config) (*sql.DB, error)

func (PGConn) ConnectAdmin

func (PGConn) ConnectAdmin(c *Config) (*sql.DB, error)

func (PGConn) Migrate

func (p PGConn) Migrate(src string, cfg *Config) (*migrate.Migrate, error)

type Postgres

type Postgres struct {
	Name         string
	EnvKeys      *EnvKeys
	MigrationSrc string
	SeedSrc      string
	DockerName   string
}

func (*Postgres) Console

func (t *Postgres) Console(c *typgo.Context) error

Console interactice for postgres

func (*Postgres) DBTool

func (t *Postgres) DBTool() *DBTool

func (*Postgres) Task

func (t *Postgres) Task() *typgo.Task

Task for postgres

Jump to

Keyboard shortcuts

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