Documentation
¶
Index ¶
- Constants
- type DB
- func (db *DB) Begin() (Tx, error)
- func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
- func (db *DB) Close() error
- func (db *DB) Exec(query string, args ...any) (sql.Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *DB) Model(v any) *query.Query
- func (db *DB) Query(q string, args ...any) (*sql.Rows, error)
- func (db *DB) QueryContext(ctx context.Context, q string, args ...any) (*sql.Rows, error)
- func (db *DB) QueryRow(query string, args ...any) *sql.Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
- func (db *DB) SQLDB() *sql.DB
- func (db *DB) Table(name string) *query.Query
- func (db *DB) Transaction(fn func(tx Tx) error) error
- func (db *DB) TransactionContext(ctx context.Context, fn func(tx Tx) error) error
- type Tx
Constants ¶
View Source
const ( MySQL = "mysql" Postgres = "postgres" )
Database driver names.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB provides main ORM interface.
func Open ¶
Open opens a MySQL database with default pooling. Deprecated: use OpenWithDriver to specify a driver explicitly.
func OpenWithDriver ¶ added in v0.1.0
OpenWithDriver opens a database with default pooling for the given driver.
func (*DB) ExecContext ¶ added in v0.0.3
ExecContext executes a raw SQL statement with a context.
func (*DB) QueryContext ¶ added in v0.0.3
QueryContext runs Query with a context.
func (*DB) QueryRow ¶ added in v0.0.3
QueryRow executes a query that is expected to return at most one row.
func (*DB) QueryRowContext ¶ added in v0.0.3
QueryRowContext executes a query with context returning at most one row.
func (*DB) Transaction ¶
Transaction executes fn in a transaction.
Click to show internal directories.
Click to hide internal directories.