camConsole

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMigration

type BaseMigration struct {
	camBase.MigrationInterface
	// contains filtered or unexported fields
}

base migration struct

func (*BaseMigration) Exec

func (model *BaseMigration) Exec(sql string)

exec sql

func (*BaseMigration) GetSqlList

func (model *BaseMigration) GetSqlList() []string

get sql list

type ConsoleComponent

type ConsoleComponent struct {
	component.Component
	camPluginRouter.RouterPlugin
	// contains filtered or unexported fields
}

command component

func (*ConsoleComponent) GetMigrateUpVersionList

func (comp *ConsoleComponent) GetMigrateUpVersionList() []string

get migrate up version list.

func (*ConsoleComponent) Init

init

func (*ConsoleComponent) MigrateDown

func (comp *ConsoleComponent) MigrateDown()

down last database version

func (*ConsoleComponent) MigrateLastVersion

func (comp *ConsoleComponent) MigrateLastVersion() string

func (*ConsoleComponent) MigrateUp

func (comp *ConsoleComponent) MigrateUp()

up all database version

func (*ConsoleComponent) RunAction

func (comp *ConsoleComponent) RunAction()

run command Example:

# go build cam.go
# ./cam controllerName/actionName param1 param2

type ConsoleComponentConfig

type ConsoleComponentConfig struct {
	component.ComponentConfig
	camPluginRouter.RouterPluginConfig

	DatabaseDir     string // DatabaseComponentConfig file storage path. Default is: /[path to run dir]/database
	XormTemplateDir string // xorm template path.
}

console config

func NewConsoleComponentConfig

func NewConsoleComponentConfig() *ConsoleComponentConfig

new console config

func (*ConsoleComponentConfig) SetDatabaseDir

func (config *ConsoleComponentConfig) SetDatabaseDir(dir string) *ConsoleComponentConfig

set migration's file dir

func (*ConsoleComponentConfig) SetXormTemplateDir

func (config *ConsoleComponentConfig) SetXormTemplateDir(dir string) *ConsoleComponentConfig

set xorm dir

type ConsoleController

type ConsoleController struct {
	camPluginRouter.Controller
}

func (*ConsoleController) GetArgv

func (ctrl *ConsoleController) GetArgv(key int) string

get params key start is 0 example:

/path/to/main.exe console/run argv0 argv1
controller.GetArgv(0) => "argv0"
controller.GetArgv(1) => "argv1"
controller.GetArgv(2) => ""
controller.GetArgv(-1) => ""

func (*ConsoleController) GetConsoleComponent

func (ctrl *ConsoleController) GetConsoleComponent() *ConsoleComponent

get console component

type MigrateController

type MigrateController struct {
	ConsoleController
}

func (*MigrateController) Create

func (ctrl *MigrateController) Create()

create migration's file

func (*MigrateController) Down

func (ctrl *MigrateController) Down()

migrate down

func (*MigrateController) Up

func (ctrl *MigrateController) Up()

migrate up

type Migration

type Migration struct {
	Version string    `xorm:"pk notnull"`
	DoneAt  time.Time `xorm:"timestamp created notnull"`
}

type MigrationTpl

type MigrationTpl struct {
	ClassName string
}

type XormController

type XormController struct {
	ConsoleController
}

xorm's console controller

func (*XormController) Generate

func (ctrl *XormController) Generate()

Generate ORM classes automatically according to the database xorm reverse

usage: xorm reverse [-s] driverName datasourceName tmplPath [generatedPath] [tableFilterReg]

according database's tables and columns to generate codes for Go, C++ and etc.

-s                Generated one go file for every table
driverName        Database driver name, now supported four: mysql mymysql sqlite3 postgres
datasourceName    Database connection uri, for detail infomation please visit driver's project page
tmplPath          Template dir for generated. the default templates dir has provide 1 template
generatedPath     This parameter is optional, if blank, the default value is model, then will
generated all codes in model dir
tableFilterReg    Table name filter regexp

func (*XormController) InstallCmdXorm

func (ctrl *XormController) InstallCmdXorm()

install github.com/go-xorm/cmd/xorm

Jump to

Keyboard shortcuts

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