Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnexpectedColumnType = errors.New("unexpected column type")
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // Connect connects to the database. Connect(ctx context.Context) error // Close closes the database connection. Close(ctx context.Context) error // GetAllTables returns all table names. GetAllTables(ctx context.Context) ([]string, error) // GetTableColumns returns all columns of the given table. GetTableColumns(ctx context.Context, tableName string) ([]TableColumn, error) // GetTableIndexes returns all indexes of the given table. GetTableIndexes(ctx context.Context, tableName string) ([]TableIndex, error) // ParseColumnType parses the given database column type to the defined type. ParseColumnType(typ string) (ColumnType, error) }
Backend is a database backend interface.
type ColumnName ¶
type ColumnName string
func (ColumnName) Lower ¶
func (c ColumnName) Lower() ColumnName
Lower transforms the lower snake case column name to lower camel case. Eggplant -> eggplant i_love_eggplant -> iLoveEggplant user_id -> userID
func (ColumnName) String ¶
func (c ColumnName) String() string
func (ColumnName) Upper ¶
func (c ColumnName) Upper() ColumnName
Upper transforms the lower snake case column name to upper camel case. eggplant -> Eggplant user_id -> UserID userID -> UserID
type ColumnType ¶
type ColumnType string
const ( ColumnTypeNumber ColumnType = "number" ColumnTypeString ColumnType = "string" ColumnTypeTime ColumnType = "time" ColumnTypeBoolean ColumnType = "boolean" )
func (ColumnType) GoType ¶
func (t ColumnType) GoType() reflect.Type
type TableColumn ¶
type TableColumn struct { TableName string Name ColumnName Type ColumnType IsNullable bool }
type TableIndex ¶
func (TableIndex) GetIndexColumns ¶
func (i TableIndex) GetIndexColumns(allColumns ...TableColumn) []TableColumn
GetIndexColumns returns the index columns of the given table columns.
type TableName ¶
type TableName string
func (TableName) LowerPlural ¶
func (TableName) LowerSingular ¶
func (TableName) SnakePlural ¶
func (TableName) SnakeSingular ¶
func (TableName) UpperPlural ¶
func (TableName) UpperSingular ¶
Click to show internal directories.
Click to hide internal directories.