Documentation
¶
Index ¶
- func MySQLFieldType(sqlType string) (f string)
- func PostgresFieldType(sqlType string) (f string)
- type ConvertOption
- func WithDriver(drv *mux.ConvertDriver) ConvertOption
- func WithExcludedTables(tables []string) ConvertOption
- func WithIncludedTables(tables []string) ConvertOption
- func WithModuleName(name string) ConvertOption
- func WithModuleVersion(ver string) ConvertOption
- func WithProtoPath(path string) ConvertOption
- func WithSchemaPath(path string) ConvertOption
- func WithServiceType(serviceType string) ConvertOption
- func WithSourceModuleName(name string) ConvertOption
- type ConvertOptions
- type FieldData
- type MySQL
- type Options
- type Postgres
- type SchemaConverter
- type TableData
- type Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MySQLFieldType ¶
func PostgresFieldType ¶
Types ¶
type ConvertOption ¶
type ConvertOption func(*ConvertOptions)
ConvertOption allows for managing import configuration using functional options.
func WithDriver ¶
func WithDriver(drv *mux.ConvertDriver) ConvertOption
WithDriver provides an import driver to be used by SchemaConverter.
func WithExcludedTables ¶
func WithExcludedTables(tables []string) ConvertOption
WithExcludedTables supplies the set of includedTables to exclude.
func WithIncludedTables ¶
func WithIncludedTables(tables []string) ConvertOption
WithIncludedTables limits the schema import to a set of given includedTables (by all includedTables are imported)
func WithModuleName ¶
func WithModuleName(name string) ConvertOption
func WithModuleVersion ¶
func WithModuleVersion(ver string) ConvertOption
func WithProtoPath ¶
func WithProtoPath(path string) ConvertOption
WithProtoPath provides a path for writing the generated protocol buffer definitions.
func WithSchemaPath ¶ added in v0.0.10
func WithSchemaPath(path string) ConvertOption
func WithServiceType ¶
func WithServiceType(serviceType string) ConvertOption
func WithSourceModuleName ¶
func WithSourceModuleName(name string) ConvertOption
type ConvertOptions ¶
type ConvertOptions struct {
// contains filtered or unexported fields
}
ConvertOptions are the options passed on to every SchemaConverter.
type FieldData ¶
type FieldData struct {
Name string // 字段名
Type string // 字段类型
Null bool // 是否允许为 NULL
Comment string // 字段注释
}
FieldData 字段数据
type MySQL ¶
type MySQL struct {
*ConvertOptions
}
MySQL holds the schema import options and an Atlas inspector instance
func NewMySQL ¶
func NewMySQL(i *ConvertOptions) (*MySQL, error)
NewMySQL - create aמ import structure for MySQL.
type Options ¶
type Options struct {
Driver string `json:"driver"` // Driver name, e.g., "mysql", "postgres"
Source string `json:"source"` // Data source name (DSN), e.g., "mysql://user:pass@tcp(localhost:3306)/dbname"
IncludedTables []string `json:"included_tables"` // IncludedTables to inspect (all if empty)
ExcludedTables []string `json:"excluded_tables"` // ExcludedTables to exclude from inspection
OutputPath string `json:"output_path"` // Path to save the generated code
SourceModule string `json:"sourceModule"` // Source module name, for REST service generate, e.g., "admin"
Module string `json:"module"` // Module name for the generated code, e.g., "admin"
Version string `json:"version"` // Version of the module, e.g., "v1"
Service string `json:"service"` // generate service code, "rest" for REST service, "grpc" for gRPC service
}
type Postgres ¶
type Postgres struct {
*ConvertOptions
}
Postgres implements SchemaConverter for PostgreSQL databases.
type SchemaConverter ¶
func NewConvert ¶
func NewConvert(opts ...ConvertOption) (SchemaConverter, error)
func NewPostgreSQL ¶
func NewPostgreSQL(i *ConvertOptions) (SchemaConverter, error)
NewPostgreSQL - returns a new *Postgres.
type TableData ¶
type TableData struct {
Name string // 表名
Comment string // 表注释
Charset string // 字符集
Collation string // 排序规则
Fields []FieldData // 字段数据
}
TableData 表数据
func (TableData) WithComment ¶
type Text ¶ added in v0.0.10
type Text struct {
*ConvertOptions
}
func NewText ¶ added in v0.0.10
func NewText(i *ConvertOptions) (*Text, error)