Documentation ¶
Index ¶
- Constants
- func AddFilterToQuery(s *schema.Schema, q sq.SelectBuilder, filter map[string]interface{}, join bool) (sq.SelectBuilder, error)
- func MakeColumns(s *schema.Schema, tableName string, fields []string, join bool) []string
- type CachedState
- type CachedTransaction
- func (tx *CachedTransaction) ClearCache()
- func (tx *CachedTransaction) Create(resource *schema.Resource) error
- func (tx *CachedTransaction) CreateContext(ctx context.Context, resource *schema.Resource) error
- func (tx *CachedTransaction) Delete(s *schema.Schema, resourceID interface{}) error
- func (tx *CachedTransaction) DeleteContext(ctx context.Context, s *schema.Schema, resourceID interface{}) error
- func (tx *CachedTransaction) Fetch(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
- func (tx *CachedTransaction) FetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (*schema.Resource, error)
- func (tx *CachedTransaction) List(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *CachedTransaction) ListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *CachedTransaction) LockFetch(s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, ...) (*schema.Resource, error)
- func (tx *CachedTransaction) LockFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (*schema.Resource, error)
- func (tx *CachedTransaction) LockList(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *CachedTransaction) LockListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *CachedTransaction) Query(s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)
- func (tx *CachedTransaction) QueryContext(ctx context.Context, s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)
- func (tx *CachedTransaction) StateUpdate(resource *schema.Resource, state *transaction.ResourceState) error
- func (tx *CachedTransaction) StateUpdateContext(ctx context.Context, resource *schema.Resource, ...) error
- func (tx *CachedTransaction) Update(resource *schema.Resource) error
- func (tx *CachedTransaction) UpdateContext(ctx context.Context, resource *schema.Resource) error
- type DB
- func (db *DB) AlterTableDef(s *schema.Schema, cascade bool) (string, []string, error)
- func (db *DB) Begin() (tx transaction.Transaction, err error)
- func (db *DB) BeginTx(ctx context.Context, options *transaction.TxOptions) (tx transaction.Transaction, err error)
- func (db *DB) Close()
- func (db *DB) Connect(sqlType, conn string, maxOpenConn int) (err error)
- func (db *DB) DropTable(s *schema.Schema) error
- func (db *DB) GenTableDef(s *schema.Schema, cascade bool) (string, []string)
- func (db *DB) Options() options.Options
- func (db *DB) RegisterTable(s *schema.Schema, cascade, migrate bool) error
- func (db *DB) SetMaxOpenConns(maxIdleConns int)
- type Transaction
- func (tx *Transaction) Close() error
- func (tx *Transaction) Closed() bool
- func (tx *Transaction) Commit() error
- func (tx *Transaction) CountContext(ctx context.Context, s *schema.Schema, filter transaction.Filter) (res uint64, err error)
- func (tx *Transaction) Create(resource *schema.Resource) error
- func (tx *Transaction) CreateContext(ctx context.Context, resource *schema.Resource) error
- func (tx *Transaction) Delete(s *schema.Schema, resourceID interface{}) error
- func (tx *Transaction) DeleteContext(ctx context.Context, s *schema.Schema, resourceID interface{}) error
- func (tx *Transaction) Exec(sql string, args ...interface{}) error
- func (tx *Transaction) ExecContext(ctx context.Context, sql string, args ...interface{}) error
- func (tx *Transaction) Fetch(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
- func (tx *Transaction) FetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (*schema.Resource, error)
- func (tx *Transaction) GetIsolationLevel() transaction.Type
- func (tx *Transaction) List(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *Transaction) ListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *Transaction) LockFetch(s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, ...) (*schema.Resource, error)
- func (tx *Transaction) LockFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (*schema.Resource, error)
- func (tx *Transaction) LockList(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *Transaction) LockListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, ...) (list []*schema.Resource, total uint64, err error)
- func (tx *Transaction) Query(s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)
- func (tx *Transaction) QueryContext(ctx context.Context, s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)
- func (tx *Transaction) RawTransaction() *sqlx.Tx
- func (tx *Transaction) StateFetch(s *schema.Schema, filter transaction.Filter) (state transaction.ResourceState, err error)
- func (tx *Transaction) StateFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter) (state transaction.ResourceState, err error)
- func (tx *Transaction) StateUpdate(resource *schema.Resource, state *transaction.ResourceState) error
- func (tx *Transaction) StateUpdateContext(ctx context.Context, resource *schema.Resource, ...) error
- func (tx *Transaction) Update(resource *schema.Resource) error
- func (tx *Transaction) UpdateContext(ctx context.Context, resource *schema.Resource) error
- type TxInterface
Constants ¶
const ( OrCondition = "__or__" AndCondition = "__and__" )
Variables ¶
This section is empty.
Functions ¶
func AddFilterToQuery ¶
func AddFilterToQuery(s *schema.Schema, q sq.SelectBuilder, filter map[string]interface{}, join bool) (sq.SelectBuilder, error)
Types ¶
type CachedState ¶
type CachedState struct {
// contains filtered or unexported fields
}
type CachedTransaction ¶
type CachedTransaction struct { TxInterface QueryCache map[string]CachedState }
func (*CachedTransaction) ClearCache ¶
func (tx *CachedTransaction) ClearCache()
func (*CachedTransaction) Create ¶
func (tx *CachedTransaction) Create(resource *schema.Resource) error
func (*CachedTransaction) CreateContext ¶
func (*CachedTransaction) Delete ¶
func (tx *CachedTransaction) Delete(s *schema.Schema, resourceID interface{}) error
func (*CachedTransaction) DeleteContext ¶
func (*CachedTransaction) Fetch ¶
func (tx *CachedTransaction) Fetch(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
func (*CachedTransaction) FetchContext ¶
func (tx *CachedTransaction) FetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
func (*CachedTransaction) List ¶
func (tx *CachedTransaction) List(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)
func (*CachedTransaction) ListContext ¶
func (tx *CachedTransaction) ListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)
List resources in the db
func (*CachedTransaction) LockFetch ¶
func (tx *CachedTransaction) LockFetch(s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, options *transaction.ViewOptions) (*schema.Resource, error)
func (*CachedTransaction) LockFetchContext ¶
func (tx *CachedTransaction) LockFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, options *transaction.ViewOptions) (*schema.Resource, error)
func (*CachedTransaction) LockList ¶
func (tx *CachedTransaction) LockList(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) (list []*schema.Resource, total uint64, err error)
func (*CachedTransaction) LockListContext ¶
func (tx *CachedTransaction) LockListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) (list []*schema.Resource, total uint64, err error)
func (*CachedTransaction) QueryContext ¶
func (*CachedTransaction) StateUpdate ¶
func (tx *CachedTransaction) StateUpdate(resource *schema.Resource, state *transaction.ResourceState) error
func (*CachedTransaction) StateUpdateContext ¶
func (tx *CachedTransaction) StateUpdateContext(ctx context.Context, resource *schema.Resource, state *transaction.ResourceState) error
func (*CachedTransaction) Update ¶
func (tx *CachedTransaction) Update(resource *schema.Resource) error
func (*CachedTransaction) UpdateContext ¶
type DB ¶
DB is sql implementation of DB
func (*DB) AlterTableDef ¶
AlterTableDef generates alter table sql
func (*DB) Begin ¶
func (db *DB) Begin() (tx transaction.Transaction, err error)
Begin starts new transaction
func (*DB) BeginTx ¶
func (db *DB) BeginTx(ctx context.Context, options *transaction.TxOptions) (tx transaction.Transaction, err error)
BeginTx starts new transaction with given transaction options
func (*DB) GenTableDef ¶
GenTableDef generates create table sql
func (*DB) RegisterTable ¶
RegisterTable creates table in the db
func (*DB) SetMaxOpenConns ¶
SetMaxOpenConns limit maximum connections
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is sql implementation of Transaction
func (*Transaction) Closed ¶
func (tx *Transaction) Closed() bool
Closed returns whether the transaction is closed
func (*Transaction) CountContext ¶
func (tx *Transaction) CountContext(ctx context.Context, s *schema.Schema, filter transaction.Filter) (res uint64, err error)
CountContext count all matching resources in the db
func (*Transaction) CreateContext ¶
Create create resource in the db
func (*Transaction) Delete ¶
func (tx *Transaction) Delete(s *schema.Schema, resourceID interface{}) error
func (*Transaction) DeleteContext ¶
func (tx *Transaction) DeleteContext(ctx context.Context, s *schema.Schema, resourceID interface{}) error
Delete delete resource from db
func (*Transaction) Exec ¶
func (tx *Transaction) Exec(sql string, args ...interface{}) error
func (*Transaction) ExecContext ¶
func (tx *Transaction) ExecContext(ctx context.Context, sql string, args ...interface{}) error
Exec executes sql in transaction
func (*Transaction) Fetch ¶
func (tx *Transaction) Fetch(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
func (*Transaction) FetchContext ¶
func (tx *Transaction) FetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions) (*schema.Resource, error)
Fetch resources by ID in the db
func (*Transaction) GetIsolationLevel ¶
func (tx *Transaction) GetIsolationLevel() transaction.Type
GetIsolationLevel returns tx isolation level
func (*Transaction) List ¶
func (tx *Transaction) List(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)
func (*Transaction) ListContext ¶
func (tx *Transaction) ListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)
List resources in the db
func (*Transaction) LockFetch ¶
func (tx *Transaction) LockFetch(s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, options *transaction.ViewOptions) (*schema.Resource, error)
func (*Transaction) LockFetchContext ¶
func (tx *Transaction) LockFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, lockPolicy schema.LockPolicy, options *transaction.ViewOptions) (*schema.Resource, error)
LockFetch fetches & locks a resource
func (*Transaction) LockList ¶
func (tx *Transaction) LockList(s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) (list []*schema.Resource, total uint64, err error)
func (*Transaction) LockListContext ¶
func (tx *Transaction) LockListContext(ctx context.Context, s *schema.Schema, filter transaction.Filter, options *transaction.ViewOptions, pg *pagination.Paginator, lockPolicy schema.LockPolicy) (list []*schema.Resource, total uint64, err error)
LockList locks resources in the db
func (*Transaction) QueryContext ¶
func (tx *Transaction) QueryContext(ctx context.Context, s *schema.Schema, query string, arguments []interface{}) (list []*schema.Resource, err error)
Query with raw sql string
func (*Transaction) RawTransaction ¶
func (tx *Transaction) RawTransaction() *sqlx.Tx
RawTransaction returns raw transaction
func (*Transaction) StateFetch ¶
func (tx *Transaction) StateFetch(s *schema.Schema, filter transaction.Filter) (state transaction.ResourceState, err error)
func (*Transaction) StateFetchContext ¶
func (tx *Transaction) StateFetchContext(ctx context.Context, s *schema.Schema, filter transaction.Filter) (state transaction.ResourceState, err error)
StateFetch fetches the state of the specified resource
func (*Transaction) StateUpdate ¶
func (tx *Transaction) StateUpdate(resource *schema.Resource, state *transaction.ResourceState) error
func (*Transaction) StateUpdateContext ¶
func (tx *Transaction) StateUpdateContext(ctx context.Context, resource *schema.Resource, state *transaction.ResourceState) error
StateUpdate update resource state
func (*Transaction) UpdateContext ¶
Update update resource in the db
type TxInterface ¶
type TxInterface transaction.Transaction
func MakeCachedTransaction ¶
func MakeCachedTransaction(transx TxInterface) TxInterface