Documentation ¶
Index ¶
- func RunTransactionWithOptions(ctx context.Context, db *sql.DB, txOpts *sql.TxOptions, ...) error
- type AlterTableSqlBuilder
- func (b *AlterTableSqlBuilder) AddColumn(col *Column) *AlterTableSqlBuilder
- func (b *AlterTableSqlBuilder) AddUniqueConstraint(name string, columns ...string) *AlterTableSqlBuilder
- func (b *AlterTableSqlBuilder) ChangeColumn(name string, col *Column) *AlterTableSqlBuilder
- func (b *AlterTableSqlBuilder) ToSQL() (string, error)
- type Column
- func (c *Column) SetDefault(value string) *Column
- func (c *Column) SetDefaultCurrentTimestamp() *Column
- func (c *Column) SetName(name string) *Column
- func (c *Column) SetNullable(nullable bool) *Column
- func (c *Column) SetPrimaryKey(pk bool) *Column
- func (c *Column) SetSize(size int) *Column
- func (c *Column) SetType(t ColumnType) *Column
- func (c *Column) String() (string, error)
- type ColumnType
- type CreateIndexSqlBuilder
- type CreateTableSqlBuilder
- func (b *CreateTableSqlBuilder) Column(column *Column) *CreateTableSqlBuilder
- func (b *CreateTableSqlBuilder) SetIfNotExists(ine bool) *CreateTableSqlBuilder
- func (b *CreateTableSqlBuilder) ToSQL() (string, error)
- func (b *CreateTableSqlBuilder) UniqueConstraint(columns ...string) *CreateTableSqlBuilder
- type DialectType
- func (d DialectType) AlterTable(name string) *AlterTableSqlBuilder
- func (d DialectType) Column(name string, t ColumnType, size OptionalInt) *Column
- func (d DialectType) CreateIndex(name, table string, columns ...string) *CreateIndexSqlBuilder
- func (d DialectType) CreateUniqueIndex(name, table string, columns ...string) *CreateIndexSqlBuilder
- func (d DialectType) DropIndex(name, table string) *DropIndexSqlBuilder
- func (d DialectType) Table(name string) *CreateTableSqlBuilder
- type DropIndexSqlBuilder
- type OptionalInt
- type OptionalString
- type RawSqlBuilder
- type SQLBuilder
- type TransactionScopedWork
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunTransactionWithOptions ¶
func RunTransactionWithOptions(ctx context.Context, db *sql.DB, txOpts *sql.TxOptions, txWork TransactionScopedWork) error
RunTransactionWithOptions executes a block of code within a database transaction.
Types ¶
type AlterTableSqlBuilder ¶
type AlterTableSqlBuilder struct { Dialect DialectType Name string Changes []string }
func (*AlterTableSqlBuilder) AddColumn ¶
func (b *AlterTableSqlBuilder) AddColumn(col *Column) *AlterTableSqlBuilder
func (*AlterTableSqlBuilder) AddUniqueConstraint ¶
func (b *AlterTableSqlBuilder) AddUniqueConstraint(name string, columns ...string) *AlterTableSqlBuilder
func (*AlterTableSqlBuilder) ChangeColumn ¶
func (b *AlterTableSqlBuilder) ChangeColumn(name string, col *Column) *AlterTableSqlBuilder
func (*AlterTableSqlBuilder) ToSQL ¶
func (b *AlterTableSqlBuilder) ToSQL() (string, error)
type Column ¶
type Column struct { Dialect DialectType Name string Nullable bool Default OptionalString Type ColumnType Size OptionalInt PrimaryKey bool }
func (*Column) SetDefault ¶
func (*Column) SetDefaultCurrentTimestamp ¶
func (*Column) SetNullable ¶
func (*Column) SetPrimaryKey ¶
func (*Column) SetType ¶
func (c *Column) SetType(t ColumnType) *Column
type ColumnType ¶
type ColumnType int
const ( ColumnTypeBool ColumnType = iota ColumnTypeSmallInt ColumnType = iota ColumnTypeInteger ColumnType = iota ColumnTypeChar ColumnType = iota ColumnTypeVarChar ColumnType = iota ColumnTypeText ColumnType = iota ColumnTypeDateTime ColumnType = iota )
func (ColumnType) Format ¶
func (d ColumnType) Format(dialect DialectType, size OptionalInt) (string, error)
type CreateIndexSqlBuilder ¶
type CreateIndexSqlBuilder struct { Dialect DialectType Name string Table string Unique bool Columns []string }
func (*CreateIndexSqlBuilder) ToSQL ¶
func (b *CreateIndexSqlBuilder) ToSQL() (string, error)
type CreateTableSqlBuilder ¶
type CreateTableSqlBuilder struct { Dialect DialectType Name string IfNotExists bool ColumnOrder []string Columns map[string]*Column Constraints []string }
func (*CreateTableSqlBuilder) Column ¶
func (b *CreateTableSqlBuilder) Column(column *Column) *CreateTableSqlBuilder
func (*CreateTableSqlBuilder) SetIfNotExists ¶
func (b *CreateTableSqlBuilder) SetIfNotExists(ine bool) *CreateTableSqlBuilder
func (*CreateTableSqlBuilder) ToSQL ¶
func (b *CreateTableSqlBuilder) ToSQL() (string, error)
func (*CreateTableSqlBuilder) UniqueConstraint ¶
func (b *CreateTableSqlBuilder) UniqueConstraint(columns ...string) *CreateTableSqlBuilder
type DialectType ¶
type DialectType int
const ( DialectSQLite DialectType = iota DialectMySQL DialectType = iota )
func (DialectType) AlterTable ¶
func (d DialectType) AlterTable(name string) *AlterTableSqlBuilder
func (DialectType) Column ¶
func (d DialectType) Column(name string, t ColumnType, size OptionalInt) *Column
func (DialectType) CreateIndex ¶
func (d DialectType) CreateIndex(name, table string, columns ...string) *CreateIndexSqlBuilder
func (DialectType) CreateUniqueIndex ¶
func (d DialectType) CreateUniqueIndex(name, table string, columns ...string) *CreateIndexSqlBuilder
func (DialectType) DropIndex ¶
func (d DialectType) DropIndex(name, table string) *DropIndexSqlBuilder
func (DialectType) Table ¶
func (d DialectType) Table(name string) *CreateTableSqlBuilder
type DropIndexSqlBuilder ¶
type DropIndexSqlBuilder struct { Dialect DialectType Name string Table string }
func (*DropIndexSqlBuilder) ToSQL ¶
func (b *DropIndexSqlBuilder) ToSQL() (string, error)
type OptionalInt ¶
var UnsetSize OptionalInt = OptionalInt{Set: false, Value: 0}
type OptionalString ¶
var UnsetDefault OptionalString = OptionalString{Set: false, Value: ""}
type RawSqlBuilder ¶
type RawSqlBuilder struct {
Query string
}
func (*RawSqlBuilder) ToSQL ¶
func (b *RawSqlBuilder) ToSQL() (string, error)
type SQLBuilder ¶
Click to show internal directories.
Click to hide internal directories.