Documentation ¶
Index ¶
- func ColumnNames(cols []*Column) []string
- func FieldNames(fields []*Field) []string
- type BaseType
- type BaseTypeNotNullable
- type BaseTypeNullable
- type Column
- type Enum
- type Field
- type ForeignKey
- type GoType
- type Index
- type Model
- func (t *Model) DeleteColumn(name string)
- func (t *Model) DeleteForeignKey(name string)
- func (t *Model) DeleteIndex(name string)
- func (t *Model) DeleteUnique(name string)
- func (t *Model) FindColumn(name string) *Column
- func (t *Model) FindField(name string) (col *Field)
- func (t *Model) FindForeignKey(name string) *ForeignKey
- func (t *Model) FindIndex(name string) *Index
- func (t *Model) FindUnique(name string) *Unique
- func (t *Model) GetColumn(name string) *Column
- func (t *Model) GetField(name string) (col *Field)
- func (t *Model) IsUniqueColumn(name string) bool
- func (m *Model) SingleColumnForeignKeys() []*ForeignKey
- type NullableType
- type PrimaryKey
- type SQLColumnDef
- type SQLColumnDefs
- type SQLType
- type Schema
- type Struct
- type Tags
- type ToManyRelationship
- type ToOneRelationship
- type Type
- type Unique
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseTypeNotNullable ¶
func (*BaseTypeNotNullable) GetName ¶
func (t *BaseTypeNotNullable) GetName() string
func (*BaseTypeNotNullable) GoType ¶
func (t *BaseTypeNotNullable) GoType() GoType
func (*BaseTypeNotNullable) SQLType ¶
func (t *BaseTypeNotNullable) SQLType() SQLType
type BaseTypeNullable ¶
func (*BaseTypeNullable) GetName ¶
func (t *BaseTypeNullable) GetName() string
func (*BaseTypeNullable) GoType ¶
func (t *BaseTypeNullable) GoType() GoType
func (*BaseTypeNullable) GoTypeNull ¶
func (t *BaseTypeNullable) GoTypeNull() GoType
func (*BaseTypeNullable) GoTypeNullField ¶
func (t *BaseTypeNullable) GoTypeNullField() string
func (*BaseTypeNullable) SQLType ¶
func (t *BaseTypeNullable) SQLType() SQLType
type Column ¶
Field holds information about a database field. Types are Go types, converted by TranslateFieldType.
type Field ¶
Field holds information about a database field. Types are Go types, converted by TranslateFieldType.
func (*Field) GenerateTags ¶
type ForeignKey ¶
type ForeignKey struct { Model string Name string Columns []string ForeignModel string ForeignColumns []string Nullable bool Unique bool ForeignColumnNullable bool ForeignColumnUnique bool }
ForeignKey represents a foreign key constraint in a database
func (*ForeignKey) Column ¶
func (f *ForeignKey) Column() string
func (*ForeignKey) ForeignColumn ¶
func (f *ForeignKey) ForeignColumn() string
type Model ¶
type Model struct { Name string Fields []*Field Columns []*Column PrimaryKey *PrimaryKey Indexes []*Index Uniques []*Unique ForeignKeys []*ForeignKey IsJoinModel bool ToOneRelationships []*ToOneRelationship ToManyRelationships []*ToManyRelationship }
Model metadata from the database schema.
func (*Model) DeleteColumn ¶
DeleteColumn by name. does nothing if not found.
func (*Model) DeleteForeignKey ¶
DeleteForeignKey by name. does nothing if not found.
func (*Model) DeleteIndex ¶
DeleteIndex by name. does nothing if not found.
func (*Model) DeleteUnique ¶
DeleteUnique by name. does nothing if not found.
func (*Model) FindColumn ¶
FindColumn by name. Returns nil if not found.
func (*Model) FindField ¶
FindField by name. Returns nil if not found (for use in templates mostly).
func (*Model) FindForeignKey ¶
func (t *Model) FindForeignKey(name string) *ForeignKey
FindForeignKey by name. Returns nil if not found.
func (*Model) FindUnique ¶
FindUnique by name. Returns nil if not found.
func (*Model) IsUniqueColumn ¶
func (*Model) SingleColumnForeignKeys ¶
func (m *Model) SingleColumnForeignKeys() []*ForeignKey
type NullableType ¶
type PrimaryKey ¶
type PrimaryKey struct {
Columns []string
}
PrimaryKey represents a primary key in a database
type SQLColumnDef ¶
SQLColumnDef formats a field name and type like an SQL field definition.
type SQLColumnDefs ¶
type SQLColumnDefs []SQLColumnDef
SQLColumnDefs has small helper functions
func SQLColDefinitions ¶
func SQLColDefinitions(cols []*Column, names []string) SQLColumnDefs
SQLColDefinitions creates a definition in sql format for a field
type Schema ¶
func (*Schema) CalculateRelationships ¶
func (s *Schema) CalculateRelationships()
type ToManyRelationship ¶
type ToManyRelationship struct { Model string Column string Nullable bool Unique bool ForeignModel string ForeignColumn string ForeignColumnNullable bool ForeignColumnUnique bool ToJoinModel bool JoinModel string JoinLocalColumn string JoinLocalColumnNullable bool JoinLocalColumnUnique bool JoinForeignColumn string JoinForeignColumnNullable bool JoinForeignColumnUnique bool }
ToManyRelationship describes a relationship between two models where the local model has no id, and the foreign model has an id that matches a field in the local model.
type ToOneRelationship ¶
type ToOneRelationship struct { Model string Column string Nullable bool Unique bool ForeignModel string ForeignColumn string ForeignColumnNullable bool ForeignColumnUnique bool }
ToOneRelationship describes a relationship between two models where the local model has no id, and the foregin model has an id that matches a field in the local model, that field is also unique which changes the dynamic into a one-to-one style, not a to-many.