Documentation ¶
Index ¶
- func BuildDefaultTableDDL(tableName string, cols []ColumnMeta) string
- func BytesToString(bs []uint8) string
- func Copy(dst interface{}, src interface{}) error
- func FindPrimaryKeyFromInformationSchema(db *sql.DB, tableName string) (primaryKey string, err error)
- func FmtFieldName(s string) string
- func GetFieldLenFromInformationSchema(db *sql.DB, tableSchema, tableName, columnName string) (int64, error)
- func GetMappings() map[string]*SqlMapping
- func LoadMappings(mappingFileName string) error
- func LoadTableInfoFromMSSqlInformationSchema(db *sql.DB, tableName string) (primaryKey map[string]*mssqlInformationSchema, err error)
- func LoadTableInfoFromPostgresInformationSchema(db *sql.DB, tableName string) (primaryKey map[string]*postgresInformationSchema, err error)
- func ParseSqlType(dbType string) (resultType string, dbTypeLen int64)
- func ProcessMappings(mappingJsonstring []byte) error
- func SqlTypeToGoType(sqlType string, nullable bool, gureguTypes bool) (string, error)
- func SqlTypeToProtobufType(sqlType string) (string, error)
- func TrimSpaceNewlineInString(s string) string
- type ColumnMeta
- type DbTableMeta
- func LoadMeta(sqlType string, db *sql.DB, sqlDatabase, tableName string) (DbTableMeta, error)
- func NewMsSqlMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
- func NewMysqlMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
- func NewPostgresMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
- func NewSqliteMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
- func NewUnknownMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
- type FieldInfo
- type ModelInfo
- type SqlMapping
- type SqlMappings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDefaultTableDDL ¶
func BuildDefaultTableDDL(tableName string, cols []ColumnMeta) string
func BytesToString ¶
func FmtFieldName ¶
fmtFieldName formats a string as a struct key
Example:
fmtFieldName("foo_id")
Output: FooID
func GetMappings ¶
func GetMappings() map[string]*SqlMapping
func LoadMappings ¶
func ParseSqlType ¶
func ProcessMappings ¶
func SqlTypeToGoType ¶
func SqlTypeToProtobufType ¶
Types ¶
type ColumnMeta ¶
type DbTableMeta ¶
type DbTableMeta interface { Columns() []ColumnMeta SqlType() string SqlDatabase() string TableName() string DDL() string }
func NewMsSqlMeta ¶
func NewMsSqlMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
func NewMysqlMeta ¶
func NewMysqlMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
func NewPostgresMeta ¶
func NewPostgresMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
func NewSqliteMeta ¶
func NewSqliteMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
func NewUnknownMeta ¶
func NewUnknownMeta(db *sql.DB, sqlType, sqlDatabase, tableName string) (DbTableMeta, error)
type ModelInfo ¶
type ModelInfo struct { Index int IndexPlus1 int PackageName string StructName string ShortStructName string TableName string Fields []string DBMeta DbTableMeta Instance interface{} CodeFields []*FieldInfo PrimaryKeyField int PrimaryKeyGoType string PrimaryKeyFieldParser string }
func GenerateStruct ¶
func GenerateStruct(sqlType string, db *sql.DB, sqlDatabase, tableName string, structName string, pkgName string, addJsonAnnotation bool, addGormAnnotation bool, addDBAnnotation bool, addProtobufAnnotation bool, gureguTypes bool, jsonNameFormat string, protobufNameFormat string, verbose bool) (*ModelInfo, error)
GenerateStruct generates a struct for the given table.
type SqlMapping ¶
type SqlMapping struct { SqlType string `json:"sql_type"` GoType string `json:"go_type"` JsonType string `json:"json_type"` ProtobufType string `json:"protobuf_type"` GureguType string `json:"guregu_type"` GoNullableType string `json:"go_nullable_type"` }
func SqlTypeToMapping ¶
func SqlTypeToMapping(sqlType string) (*SqlMapping, error)
type SqlMappings ¶
type SqlMappings struct {
SqlMappings []*SqlMapping `json:"mappings"`
}
Click to show internal directories.
Click to hide internal directories.