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 { Name string Type string DBType string Default string Nullable bool Unique bool Validated bool // Postgres only extension bits // 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 }
Column holds information about a database column. Types are Go types, converted by TranslateColumnType.
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 ToOneRelationships []ToOneRelationship ToManyRelationships []ToManyRelationship }
Table metadata from the database schema.
func Tables ¶
Tables returns the metadata for all tables, minus the tables specified in the blacklist.
func (Table) CanLastInsertID ¶
CanLastInsertID checks the following: 1. Is there only one primary key? 2. Does the primary key column have a default value? 3. Is the primary key column type one of uintX/intX? If the above is all true, this table can use LastInsertId
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
type ToOneRelationship ¶
type ToOneRelationship struct { Table string Column string Nullable bool Unique bool ForeignTable string ForeignColumn string ForeignColumnNullable bool ForeignColumnUnique bool }
ToOneRelationship describes a relationship between two tables where the local table has no id, and the foregin table has an id that matches a column in the local table, that column is also unique which changes the dynamic into a one-to-one style, not a to-many.
func ToOneRelationships ¶
func ToOneRelationships(table string, tables []Table) []ToOneRelationship
ToOneRelationships relationship lookups Input should be the sql name of a table like: videos