-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsql_query.go
56 lines (49 loc) · 2.64 KB
/
sql_query.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
48
49
50
51
52
53
54
55
56
package dbx
import (
"context"
"database/sql"
)
type sqlExecutor interface {
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
Exec(query string, args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Prepare(query string) (*sql.Stmt, error)
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}
type mapperExecutor interface {
Execute(sql string, params ...interface{}) (lastInsertId, rowsAffected int64, err error)
Insert(model interface{}) (rs sql.Result, err error)
InsertContext(ctx context.Context, model interface{}) (rs sql.Result, err error)
Update(model interface{}) (rs sql.Result, err error)
UpdateContext(ctx context.Context, model interface{}) (rs sql.Result, err error)
Find(resultSlice interface{}, query string, params ...interface{}) (err error)
FindContext(ctx context.Context, resultSlice interface{}, query string, params ...interface{}) (err error)
FindExample(querier interface{}, resultSlice interface{}) (err error)
FindExampleContext(ctx context.Context, querier interface{}, resultSlice interface{}) (err error)
Select(mapper RowsMapper, resultSlice interface{}, sql string, params ...interface{}) (err error)
SelectContext(ctx context.Context, mapper RowsMapper, resultSlice interface{}, sql string, params ...interface{}) (err error)
Get(out interface{}, sql string, params ...interface{}) (ok bool, err error)
GetContext(ctx context.Context, out interface{}, sql string, params ...interface{}) (ok bool, err error)
GetOne(out interface{}) (ok bool, err error)
GetOneContext(ctx context.Context, out interface{}) (ok bool, err error)
GetInt32(sql string, params ...interface{}) (rv int32, err error)
GetInt64(sql string, params ...interface{}) (rv int64, err error)
}
type Scaner interface {
Scan(dest ...interface{}) error
}
type sqlPrepareExecutor interface {
Query(args ...interface{}) (*sql.Rows, error)
QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
QueryRow(args ...interface{}) *sql.Row
QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
Exec(args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
}
type mapperPrepareExecutor interface {
Execute(params ...interface{}) (rowsAffected int64, err error)
ExecuteContext(ctx context.Context, params ...interface{}) (rowsAffected int64, err error)
}