Documentation
¶
Overview ¶
Package schema provide a general interface to obtain schema information from a database
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column interface {
Namer
Index() int
Type() string
// GoType should be the equivalent go type
GoType() interface{}
// IsPrimary return true if the column is part of the Primary Key, with int being the index. Otherwise, bool will be false, and int will be -1
IsPrimary() (bool, int)
Nullable() bool
Default() (interface{}, error)
Hidden() bool
}
Column describes a Column in a table
type Database ¶
type Database interface {
Databaser
Namer
// Schemata returns all the schema's in the database
Schemata() ([]Schema, error)
// SchemaName is the name of the default schema
SchemaName() string
// Schema interface functions other then Name should be for the default schema.
Schema
}
Database describes a generic database, an database provider could have additional functions
type ForeignKey ¶
type NamedSQLer ¶
type NullColumns ¶
type NullColumns struct{}
func (NullColumns) Columns ¶
func (col NullColumns) Columns() ([]Column, error)
type NullDatabase ¶
type NullDatabase struct {
}
NullDatabase can be embedded into another Struct to get some basic functions to satisfy the Database interface
func (NullDatabase) SchemaName ¶
func (db NullDatabase) SchemaName() string
func (NullDatabase) Schemata ¶
func (db NullDatabase) Schemata() ([]Schema, error)
type NullForeignKey ¶
type NullForeignKey struct{}
func (NullForeignKey) ID ¶
func (ForeignKey NullForeignKey) ID() int
func (NullForeignKey) Match ¶
func (foreignKey NullForeignKey) Match() string
func (NullForeignKey) OnDelete ¶
func (foreignKey NullForeignKey) OnDelete() string
func (NullForeignKey) OnUpdate ¶
func (foreignKey NullForeignKey) OnUpdate() string
type NullForeignKeys ¶
type NullForeignKeys struct{}
func (NullForeignKeys) ForeignKeys ¶
func (foreignKeys NullForeignKeys) ForeignKeys() ([]ForeignKey, error)
type NullSchema ¶
type NullSchema struct{}
NullSchema can be embedded into another Struct to get some basic functions to satisfy the Schema interface
func (NullSchema) Indexes ¶
func (schema NullSchema) Indexes() ([]Index, error)
func (NullSchema) Tables ¶
func (schema NullSchema) Tables() ([]Table, error)
func (NullSchema) Triggers ¶
func (schema NullSchema) Triggers() ([]Trigger, error)
func (NullSchema) Views ¶
func (schema NullSchema) Views() ([]View, error)
type NullTable ¶
type NullTable struct {
NullColumns
NullForeignKeys
}
type Schema ¶
type Schema interface {
Namer
// Tables returns the tables in the schema
Tables() ([]Table, error)
// Views returns the views in the schema
Views() ([]View, error)
Indexes() ([]Index, error)
Triggers() ([]Trigger, error)
}
Schema contains the tables, views, triggers and indexes of the database
type Table ¶
type Table interface {
NamedSQLer
// Columns in the table
Columns() ([]Column, error)
// Temporary table or not
Temporary() bool
ForeignKeys() ([]ForeignKey, error)
// Triggers on this table
Triggers() ([]Trigger, error)
Indexes() ([]Index, error)
}
Table describes a table in the database
type Trigger ¶
type Trigger interface {
NamedSQLer
Table() string
}
type View ¶
type View interface {
NamedSQLer
Columns() ([]Column, error)
}
Click to show internal directories.
Click to hide internal directories.