Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotInTransaction is returned when using Commit // outside of a transaction. ErrNotInTransaction = errors.New("not in transaction") // ErrIncompatibleOption is returned when using an option incompatible // with the selected driver. ErrIncompatibleOption = errors.New("incompatible option") )
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver interface { sqlx.Execer sqlx.ExecerContext sqlx.Queryer sqlx.QueryerContext QueryRow(string, ...interface{}) *sql.Row QueryRowContext(context.Context, string, ...interface{}) *sql.Row sqlx.Preparer sqlx.PreparerContext BindNamed(query string, arg interface{}) (string, []interface{}, error) DriverName() string Get(dest interface{}, query string, args ...interface{}) error MustExec(query string, args ...interface{}) sql.Result NamedExec(query string, arg interface{}) (sql.Result, error) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error) PrepareNamed(query string) (*sqlx.NamedStmt, error) Preparex(query string) (*sqlx.Stmt, error) Rebind(query string) string Select(dest interface{}, query string, args ...interface{}) error }
A Driver can query the database. It can either be a *sqlx.DB or a *sqlx.Tx and therefore is limited to the methods they have in common.
type Node ¶
type Node interface { Driver // Close the underlying sqlx connection. Close() error // Begin a new transaction. Beginx() (Node, error) // Rollback the associated transaction. Rollback() error // Commit the assiociated transaction. Commit() error // Tx returns the underlying transaction. Tx() *sqlx.Tx // Load returns the value stored in the map for a key, or nil if no // value is present. // The ok result indicates whether value was found in the map. Load(key interface{}) (value interface{}, ok bool) // Store sets the value for a key. Store(key, value interface{}) // LoadOrStore returns the existing value for the key if present. // Otherwise, it stores and returns the given value. // The loaded result is true if the value was loaded, false if stored. LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) // Delete deletes the value for a key. Delete(key interface{}) // Range calls f sequentially for each key and value present in the map. // If f returns false, range stops the iteration. // // Range does not necessarily correspond to any consistent snapshot of the Map's // contents: no key will be visited more than once, but if the value for any key // is stored or deleted concurrently, Range may reflect any mapping for that key // from any point during the Range call. // // Range may be O(N) with the number of elements in the map even if f returns // false after a constant number of calls. Range(f func(key, value interface{}) bool) // DeferToCommit defers the execution of the given function until (if) the // transaction is committed. Deferred function calls are pushed onto a stack. // After the transaction commits, its deferred calls are executed in a // different goroutine, in last-in-first-out order. DeferToCommit(f func()) // DeferToRollback defers the execution of the given function until (if) the // transaction is aborted. Deferred function calls are pushed onto a stack. // After the transaction aborts, its deferred calls are executed in a // different goroutine, in last-in-first-out order. DeferToRollback(f func()) }
A Node is a database driver that can manage nested transactions.
Click to show internal directories.
Click to hide internal directories.