Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TypesMap = map[string]TypeConf{
"int": {"qb.Int()", "0"},
"uint": {"qb.Int().Unsigned()", "0"},
"int64": {"qb.BigInt()", "0"},
"uint64": {"qb.BigInt().Unsigned()", "0"},
"string": {"qb.Varchar()", `""`},
"*string": {"qb.Varchar()", "nil"},
"bool": {"qb.Boolean()", "false"},
"time.Time": {"qb.Timestamp()", "(time.Time{})"},
"*time.Time": {"qb.Timestamp()", "nil"},
"uuid.UUID": {"qb.UUID()", "(uuid.UUID{})"},
"uuid.NullUUID": {"qb.UUID()", "(uuid.NullUUID{})"},
}
TypesMap associate column types and empty values to go types. It is used to guess the column type at generation time.
Functions ¶
Types ¶
type ColumnTags ¶
type ColumnTags struct { ColumnName string Type string PrimaryKey bool AutoIncrement bool Null bool NotNull bool ForeignKeys []string Indexes []string UniqueIndexes []string TextMarshaled bool }
ColumnTags contains tags set on the fields
type FKData ¶
type FKData struct { Column *FieldData RefTable *StructData RefColumn *FieldData OnUpdate string OnDelete string }
FKData describe a foreign key
type FieldData ¶
type FieldData struct { Tags ColumnTags Name string NameConst string Type string EmptyValue string ColumnName string ColumnType string ColumnModifiers string ColumnNameConst string FromEmbedded bool }
FieldData describes a field to be mapped
type StructData ¶
type StructData struct { Imported bool Name string PrivateBasename string TableName string Fields []FieldData PKeyFields []*FieldData AutoIncrementPKey *FieldData Indexes map[string][]int UniqueIndexes map[string][]int ForeignKeys []FKData NoTable bool Embed []string File FileData }
StructData describes a struct to be mapped
func ParseDir ¶
func ParseDir(path string) ([]*StructData, error)
ParseDir parses all the go files in a directory and returns their mapped structs
func ParseFile ¶
func ParseFile(path string) ([]*StructData, error)
ParseFile parses a file and returns found structs that should be mapped
Click to show internal directories.
Click to hide internal directories.