Documentation ¶
Index ¶
- func DefaultLogger(message, tid string, err error, d time.Duration, query string)
- type Cursor
- type DB
- func (d *DB) Close() (err error)
- func (d *DB) Ping(ctx context.Context) (err error)
- func (d *DB) Read(ctx context.Context, tid string) (tx *Tx, err error)
- func (d *DB) Tx(ctx context.Context, tid string, opts *sql.TxOptions) (tx *Tx, err error)
- func (d *DB) Update(ctx context.Context, tid string) (tx *Tx, err error)
- type Logger
- type Stmt
- type Tx
- func (t *Tx) Commit() (err error)
- func (t *Tx) Cursor(stmt statement.Statement) (i *Cursor, err error)
- func (t *Tx) Exec(stmt statement.Statement) (r sql.Result, err error)
- func (t *Tx) ExecSQL(query string, values ...interface{}) (r sql.Result, err error)
- func (t *Tx) Prepare(query string) (stmt *Stmt, err error)
- func (t *Tx) Query(dst interface{}, stmt statement.Statement) (err error)
- func (t *Tx) QueryCache(dst interface{}, stmt statement.Statement) (err error)
- func (t *Tx) QueryCacheSQL(dst interface{}, query string, values ...interface{}) (err error)
- func (t *Tx) QuerySQL(dst interface{}, query string, values ...interface{}) (err error)
- func (t *Tx) Rollback() (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is a cursor to a database result set.
func (*Cursor) Close ¶
Close closes the Cursor, preventing further enumeration. If Next is called and returns false and there are no further result sets, the Cursor is closed automatically and it will suffice to check the result of Err. Close is idempotent and does not affect the result of Err.
func (*Cursor) Err ¶
Err returns the error, if any, that was encountered during iteration. Err may be called after an explicit or implicit Close.
func (*Cursor) Next ¶
Next prepares the next result row for reading with the Scan method. It returns true on success, or false if there is no next result row or an error happened while preparing it. Err should be consulted to distinguish between the two cases.
Every call to Scan, even the first one, must be preceded by a call to Next.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is safe sql.DB wrapper which enforces transactional access to the database, transaction query caching and operation logging and plays nicely with `noorm/statement`.
func New ¶
New creates a new database from an existing *sql.DB with the given sql.IsolationLevel and logger.
func (*DB) Close ¶ added in v0.1.9
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
func (*DB) Ping ¶ added in v0.1.8
PingContext verifies a connection to the database is still alive, establishing a connection if necessary.
func (*DB) Read ¶
Read creates a read-only transaction with the default DB isolation level. The tid argument is the transaction identifier that will be used to log operations done within the transaction.
type Stmt ¶ added in v0.2.11
type Stmt struct {
// contains filtered or unexported fields
}
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx represents a database transaction
func (*Tx) Cursor ¶
Cursor executes a query that returns a database cursor like sql.Rows. It its useful for working with large result sets or/and when memory utilization is a concern.
The caller must call Cursor.Close() on the returned cursor in order to release the sql.Rows resources.
func (*Tx) ExecSQL ¶ added in v0.2.2
ExecSQL is like Exec but accepts a raw SQL statement and values for interpolation
func (*Tx) Prepare ¶ added in v0.2.11
Prepare creates a prepared statement for use within a transaction.
func (*Tx) QueryCache ¶
QueryCache is like Query, but will add query results to or return already cached results from the transaction query cache.
func (*Tx) QueryCacheSQL ¶ added in v0.2.2
QueryCacheSQL is like QueryCache but accepts a raw SQL statement and values for interpolation