Documentation ¶
Index ¶
- Constants
- func GoImport(pgType string, nullable, useSQLNull bool) string
- func GoNullable(pgType string, useSQLNull bool, customTypes CustomTypeMapping) (string, error)
- func GoSlice(pgType string, dimensions int) (string, error)
- func GoType(pgType string) (string, error)
- type Column
- type CustomType
- type CustomTypeMapping
- type Entity
- type Relation
Constants ¶
View Source
const ( // TypePGInt2 is a postgres type TypePGInt2 = "int2" // TypePGInt4 is a postgres type TypePGInt4 = "int4" // TypePGInt8 is a postgres type TypePGInt8 = "int8" // TypePGNumeric is a postgres type TypePGNumeric = "numeric" // TypePGFloat4 is a postgres type TypePGFloat4 = "float4" // TypePGFloat8 is a postgres type TypePGFloat8 = "float8" // TypePGText is a postgres type TypePGText = "text" // TypePGVarchar is a postgres type TypePGVarchar = "varchar" // TypePGUuid is a postgres type TypePGUuid = "uuid" // TypePGBpchar is a postgres type TypePGBpchar = "bpchar" // TypePGBytea is a postgres type TypePGBytea = "bytea" // TypePGBool is a postgres type TypePGBool = "bool" // TypePGTimestamp is a postgres type TypePGTimestamp = "timestamp" // TypePGTimestamptz is a postgres type TypePGTimestamptz = "timestamptz" // TypePGDate is a postgres type TypePGDate = "date" // TypePGTime is a postgres type TypePGTime = "time" // TypePGTimetz is a postgres type TypePGTimetz = "timetz" // TypePGInterval is a postgres type TypePGInterval = "interval" // TypePGJSONB is a postgres type TypePGJSONB = "jsonb" // TypePGJSON is a postgres type TypePGJSON = "json" // TypePGHstore is a postgres type TypePGHstore = "hstore" // TypePGInet is a postgres type TypePGInet = "inet" // TypePGCidr is a postgres type TypePGCidr = "cidr" // TypePGPoint is a postgres type TypePGPoint = "point" // TypeInt is a go type TypeInt = "int" // TypeInt32 is a go type TypeInt32 = "int32" // TypeInt64 is a go type TypeInt64 = "int64" // TypeFloat32 is a go type TypeFloat32 = "float32" // TypeFloat64 is a go type TypeFloat64 = "float64" // TypeString is a go type TypeString = "string" // TypeByteSlice is a go type TypeByteSlice = "[]byte" // TypeBool is a go type TypeBool = "bool" // TypeTime is a go type TypeTime = "time.Time" // TypeDuration is a go type TypeDuration = "time.Duration" // TypeMapInterface is a go type TypeMapInterface = "map[string]interface{}" // TypeMapString is a go type TypeMapString = "map[string]string" // TypeIP is a go type TypeIP = "net.IP" // TypeIPNet is a go type TypeIPNet = "net.IPNet" // TypeInterface is a go type TypeInterface = "interface{}" )
Variables ¶
This section is empty.
Functions ¶
func GoNullable ¶
func GoNullable(pgType string, useSQLNull bool, customTypes CustomTypeMapping) (string, error)
GoNullable generates all go types from Postgres type with pointer
Types ¶
type Column ¶
type Column struct { GoName string PGName string Type string SearchType string GoType string PGType string Nullable bool IsArray bool Dimensions int IsPK bool IsFK bool // Relation *Relation Relation *columnRelWrap Import string MaxLen int Values []string }
Column stores information about column
func NewColumn ¶
func NewColumn(pgName string, pgType string, nullable, sqlNulls, array bool, dims int, pk, fk bool, len int, values []string, customTypes CustomTypeMapping) Column
NewColumn creates Column from Postgres info
func (*Column) AddRelation ¶
AddRelation adds relation to column. Should be used if FK
type CustomType ¶
type CustomTypeMapping ¶
type CustomTypeMapping map[string]CustomType
func ParseCustomTypes ¶
func ParseCustomTypes(raw []string) (CustomTypeMapping, error)
func (CustomTypeMapping) Add ¶
func (c CustomTypeMapping) Add(pgType, goType, goImport string)
func (CustomTypeMapping) GoImport ¶
func (c CustomTypeMapping) GoImport(pgType string) (string, bool)
func (CustomTypeMapping) Has ¶
func (c CustomTypeMapping) Has(pgType string) bool
func (CustomTypeMapping) Imports ¶
func (c CustomTypeMapping) Imports() []string
type Entity ¶
type Entity struct { GoName string GoNamePlural string PGName string PGSchema string PGFullName string ViewName string Columns []Column Relations []Relation Imports []string // contains filtered or unexported fields }
Entity stores information about table
func (*Entity) AddRelation ¶
AddRelation adds relation to entity
func (*Entity) HasMultiplePKs ¶
HasMultiplePKs checks if entity has many primary keys
type Relation ¶
type Relation struct { PKFields []string FKFields []string GoName string TargetPGName string TargetPGSchema string TargetPGFullName string TargetEntity *Entity GoType string }
Relation stores relation
Click to show internal directories.
Click to hide internal directories.