Documentation ¶
Index ¶
- func MakeColumns(s *schema.Schema, tableName string, join bool) []string
- type DB
- func (db *DB) AlterTableDef(s *schema.Schema, cascade bool) (string, []string, error)
- func (db *DB) Begin() (transaction.Transaction, 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) RegisterTable(s *schema.Schema, cascade 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) Create(resource *schema.Resource) error
- func (tx *Transaction) Delete(s *schema.Schema, resourceID interface{}) error
- func (tx *Transaction) Exec(sql string, args ...interface{}) error
- func (tx *Transaction) Fetch(s *schema.Schema, filter transaction.Filter) (*schema.Resource, error)
- func (tx *Transaction) List(s *schema.Schema, filter transaction.Filter, pg *pagination.Paginator) (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) RawTransaction() *sqlx.Tx
- func (tx *Transaction) SetIsolationLevel(level transaction.Type) error
- func (tx *Transaction) StateFetch(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) Update(resource *schema.Resource) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
DB is sql implementation of DB
func (*DB) AlterTableDef ¶
AlterTableDef generates alter table sql
func (*DB) Begin ¶
func (db *DB) Begin() (transaction.Transaction, error)
Begin starts new transaction
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) Create ¶
func (tx *Transaction) Create(resource *schema.Resource) error
Create create resource in the db
func (*Transaction) Delete ¶
func (tx *Transaction) Delete(s *schema.Schema, resourceID interface{}) error
Delete delete resource from db
func (*Transaction) Exec ¶
func (tx *Transaction) Exec(sql string, args ...interface{}) error
Exec executes sql in transaction
func (*Transaction) Fetch ¶
func (tx *Transaction) Fetch(s *schema.Schema, filter transaction.Filter) (*schema.Resource, error)
Fetch resources by ID in the db
func (*Transaction) List ¶
func (tx *Transaction) List(s *schema.Schema, filter transaction.Filter, pg *pagination.Paginator) (list []*schema.Resource, total uint64, err error)
List resources in the db
func (*Transaction) Query ¶
func (tx *Transaction) Query(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) SetIsolationLevel ¶
func (tx *Transaction) SetIsolationLevel(level transaction.Type) error
SetIsolationLevel specify transaction isolation level
func (*Transaction) StateFetch ¶
func (tx *Transaction) StateFetch(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
StateUpdate update resource state