Documentation ¶
Overview ¶
Package bdb supplies the sql(b)oiler (d)ata(b)ase abstractions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnDBTypes ¶
ColumnDBTypes of the columns.
Types ¶
type Column ¶
type Column struct { // ArrType is the underlying data type of the Postgres // ARRAY type. See here: // https://www.postgresql.org/docs/9.1/static/infoschema-element-types.html ArrType *string UDTName string Name string Type string DBType string Default string Nullable bool Unique bool Validated bool }
Column holds information about a database column. Types are Go types, converted by TranslateColumnType.
func AutoIncPrimaryKey ¶
func AutoIncPrimaryKey(cols []Column, pkey *PrimaryKey) *Column
AutoIncPrimaryKey returns the auto-increment primary key column name or an empty string. Primary key columns with default values are presumed to be auto-increment, because pkeys need to be unique and a static default value would cause collisions.
func FilterColumnsByDefault ¶
FilterColumnsByDefault generates the list of columns that have default values
type ForeignKey ¶
type ForeignKey struct { Table string Name string Column string Nullable bool Unique bool ForeignTable string ForeignColumn string ForeignColumnNullable bool ForeignColumnUnique bool }
ForeignKey represents a foreign key constraint in a database
type Interface ¶
type Interface interface { TableNames(schema string, whitelist, blacklist []string) ([]string, error) Columns(schema, tableName string) ([]Column, error) PrimaryKeyInfo(schema, tableName string) (*PrimaryKey, error) ForeignKeyInfo(schema, tableName string) ([]ForeignKey, error) // TranslateColumnType takes a Database column type and returns a go column type. TranslateColumnType(Column) Column // UseLastInsertID should return true if the driver is capable of using // the sql.Exec result's LastInsertId UseLastInsertID() bool // Open the database connection Open() error // Close the database connection Close() // Dialect helpers, these provide the values that will go into // a queries.Dialect, so the query builder knows how to support // your database driver properly. LeftQuote() byte RightQuote() byte IndexPlaceholders() bool }
Interface for a database driver. Functionality required to support a specific database type (eg, MySQL, Postgres etc.)
type PrimaryKey ¶
PrimaryKey represents a primary key constraint in a database
type SQLColumnDef ¶
SQLColumnDef formats a column name and type like an SQL column 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 column
type Table ¶
type Table struct { Name string // For dbs with real schemas, like Postgres. // Example value: "schema_name"."table_name" SchemaName string Columns []Column PKey *PrimaryKey FKeys []ForeignKey IsJoinTable bool ToManyRelationships []ToManyRelationship }
Table metadata from the database schema.
type ToManyRelationship ¶
type ToManyRelationship struct { Table string Column string Nullable bool Unique bool ForeignTable string ForeignColumn string ForeignColumnNullable bool ForeignColumnUnique bool ToJoinTable bool JoinTable string JoinLocalColumn string JoinLocalColumnNullable bool JoinLocalColumnUnique bool JoinForeignColumn string JoinForeignColumnNullable bool JoinForeignColumnUnique bool }
ToManyRelationship describes a relationship between two tables where the local table has no id, and the foreign table has an id that matches a column in the local table.
func ToManyRelationships ¶
func ToManyRelationships(table string, tables []Table) []ToManyRelationship
ToManyRelationships relationship lookups Input should be the sql name of a table like: videos