Documentation ¶
Index ¶
- Constants
- type Database
- func (s *Database) AcquireLockTx(ctx context.Context, lockName string, tx *TXWrapper) error
- func (s *Database) BeginOrUseTx(ctx context.Context) (ctx1 context.Context, tx *TXWrapper, autoCommit bool, err error)
- func (s *Database) BuildUpdate(sel sq.UpdateBuilder, update ffapi.Update, typeMap map[string]string) (sq.UpdateBuilder, error)
- func (s *Database) Close()
- func (s *Database) CommitTx(ctx context.Context, tx *TXWrapper, autoCommit bool) error
- func (s *Database) ConnLimit() int
- func (s *Database) CountQuery(ctx context.Context, table string, tx *TXWrapper, fop sq.Sqlizer, ...) (count int64, err error)
- func (s *Database) DB() *sql.DB
- func (s *Database) DeleteTx(ctx context.Context, table string, tx *TXWrapper, q sq.DeleteBuilder, ...) error
- func (s *Database) FilterSelect(ctx context.Context, tableName string, sel sq.SelectBuilder, ...) (sq.SelectBuilder, sq.Sqlizer, *ffapi.FilterInfo, error)
- func (s *Database) FilterUpdate(ctx context.Context, update sq.UpdateBuilder, filter ffapi.Filter, ...) (sq.UpdateBuilder, error)
- func (s *Database) Init(ctx context.Context, provider Provider, config config.Section) (err error)
- func (s *Database) InitConfig(provider Provider, config config.Section)
- func (s *Database) InsertTx(ctx context.Context, table string, tx *TXWrapper, q sq.InsertBuilder, ...) (int64, error)
- func (s *Database) InsertTxExt(ctx context.Context, table string, tx *TXWrapper, q sq.InsertBuilder, ...) (int64, error)
- func (s *Database) InsertTxRows(ctx context.Context, table string, tx *TXWrapper, q sq.InsertBuilder, ...) error
- func (s *Database) Query(ctx context.Context, table string, q sq.SelectBuilder) (*sql.Rows, *TXWrapper, error)
- func (s *Database) QueryRes(ctx context.Context, table string, tx *TXWrapper, fop sq.Sqlizer, ...) *ffapi.FilterResult
- func (s *Database) QueryTx(ctx context.Context, table string, tx *TXWrapper, q sq.SelectBuilder) (*sql.Rows, *TXWrapper, error)
- func (s *Database) RollbackTx(ctx context.Context, tx *TXWrapper, autoCommit bool)
- func (s *Database) RunAsGroup(ctx context.Context, fn func(ctx context.Context) error) error
- func (s *Database) SequenceColumn() string
- func (s *Database) UpdateTx(ctx context.Context, table string, tx *TXWrapper, q sq.UpdateBuilder, ...) (int64, error)
- type PreCommitAccumulator
- type Provider
- type SQLFeatures
- type TXWrapper
Constants ¶
View Source
const ( // SQLConfMigrationsAuto enables automatic migrations SQLConfMigrationsAuto = "migrations.auto" // SQLConfMigrationsDirectory is the directory containing the numerically ordered migration DDL files to apply to the database SQLConfMigrationsDirectory = "migrations.directory" // SQLConfDatasourceURL is the datasource connection URL string SQLConfDatasourceURL = "url" // SQLConfMaxConnections maximum connections to the database SQLConfMaxConnections = "maxConns" // SQLConfMaxConnIdleTime maximum connections to the database SQLConfMaxConnIdleTime = "maxConnIdleTime" // SQLConfMaxIdleConns maximum connections to the database SQLConfMaxIdleConns = "maxIdleConns" // SQLConfMaxConnLifetime maximum connections to the database SQLConfMaxConnLifetime = "maxConnLifetime" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) AcquireLockTx ¶
func (*Database) BeginOrUseTx ¶
func (*Database) BuildUpdate ¶
func (s *Database) BuildUpdate(sel sq.UpdateBuilder, update ffapi.Update, typeMap map[string]string) (sq.UpdateBuilder, error)
func (*Database) CountQuery ¶
func (*Database) FilterSelect ¶
func (*Database) FilterUpdate ¶
func (*Database) InitConfig ¶
func (*Database) InsertTxExt ¶
func (*Database) InsertTxRows ¶
func (*Database) RollbackTx ¶
RollbackTx be safely called as a defer, as it is a cheap no-op if the transaction is complete
func (*Database) RunAsGroup ¶
func (*Database) SequenceColumn ¶
type PreCommitAccumulator ¶
PreCommitAccumulator is a structure that can accumulate state during the transaction, then has a function that is called just before commit.
type Provider ¶
type Provider interface { // Name is the name of the database driver Name() string // MigrationDir is the subdirectory for migrations MigrationsDir() string // SequenceColumn is the name of the sequence column to use SequenceColumn() string // Open creates the DB instances Open(url string) (*sql.DB, error) // GetDriver returns the driver implementation GetMigrationDriver(*sql.DB) (migratedb.Driver, error) // Features returns database specific configuration switches Features() SQLFeatures // ApplyInsertQueryCustomizations updates the INSERT query for returning the Sequence, and returns whether it needs to be run as a query to return the Sequence field ApplyInsertQueryCustomizations(insert sq.InsertBuilder, requestConflictEmptyResult bool) (updatedInsert sq.InsertBuilder, runAsQuery bool) }
Provider defines the interface an individual provider muse implement to customize the Database implementation
type SQLFeatures ¶
type SQLFeatures struct { UseILIKE bool MultiRowInsert bool PlaceholderFormat sq.PlaceholderFormat AcquireLock func(lockName string) string }
func DefaultSQLProviderFeatures ¶
func DefaultSQLProviderFeatures() SQLFeatures
type TXWrapper ¶
type TXWrapper struct {
// contains filtered or unexported fields
}
func (*TXWrapper) AddPostCommitHook ¶
func (tx *TXWrapper) AddPostCommitHook(fn func())
func (*TXWrapper) PreCommitAccumulator ¶
func (tx *TXWrapper) PreCommitAccumulator() PreCommitAccumulator
func (*TXWrapper) SetPreCommitAccumulator ¶
func (tx *TXWrapper) SetPreCommitAccumulator(pca PreCommitAccumulator)
Click to show internal directories.
Click to hide internal directories.