mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Add Query methods to dbutil.Execable
This commit is contained in:
parent
0cd3fcce0c
commit
b6fcbbf6b9
1 changed files with 22 additions and 1 deletions
|
|
@ -52,11 +52,32 @@ type Scannable interface {
|
|||
Scan(...interface{}) error
|
||||
}
|
||||
|
||||
type Execable interface {
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
// Expected implementations of Scannable
|
||||
var (
|
||||
_ Scannable = (*sql.Row)(nil)
|
||||
_ Scannable = (*sql.Rows)(nil)
|
||||
)
|
||||
|
||||
type ContextExecable interface {
|
||||
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
|
||||
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
|
||||
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
type Execable interface {
|
||||
ContextExecable
|
||||
Exec(query string, args ...interface{}) (sql.Result, error)
|
||||
Query(query string, args ...interface{}) (*sql.Rows, error)
|
||||
QueryRow(query string, args ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
// Expected implementations of Execable
|
||||
var (
|
||||
_ Execable = (*sql.Tx)(nil)
|
||||
_ Execable = (*sql.DB)(nil)
|
||||
_ ContextExecable = (*sql.Conn)(nil)
|
||||
)
|
||||
|
||||
type Database struct {
|
||||
*sql.DB
|
||||
Owner string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue