-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathdb.go
25 lines (21 loc) · 831 Bytes
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package qrm
import (
"context"
"database/sql"
)
// DB is common database interface used by query result mapping
// Both *sql.DB and *sql.Tx implements DB interface
type DB interface {
Exec(query string, args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
// Queryable interface for sql QueryContext method
type Queryable interface {
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
// Executable interface for sql ExecContext method
type Executable interface {
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}