-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgsql_constraints.go
47 lines (39 loc) · 913 Bytes
/
gsql_constraints.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gsql
import (
"context"
"database/sql"
"io"
"github.com/mitranim/gg"
)
// Implemented by stdlib types such as `sql.DB`.
type Db interface {
DbConn
DbTxer
}
// Implemented by stdlib types such as `sql.DB`.
type DbTxer interface {
BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}
// Implemented by stdlib types such as `sql.Conn` and `sql.Tx`.
type DbConn interface {
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
ExecContext(context.Context, string, ...any) (sql.Result, error)
}
// Implemented by stdlib types such as `sql.Tx`.
type DbTx interface {
DbConn
Commit() error
Rollback() error
}
// Interface of `sql.Rows`. Used by various scanning tools.
type Rows interface {
io.Closer
gg.Errer
gg.Nexter
ColumnerScanner
}
// Sub-interface of `Rows` used by `ScanNext`.
type ColumnerScanner interface {
Columns() ([]string, error)
Scan(...any) error
}