forked from go-kivik/kivik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rows.go
80 lines (63 loc) · 1.53 KB
/
rows.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package mock
import "github.com/IG-Soft/kivik/v3/driver"
// Rows mocks driver.Rows
type Rows struct {
// ID identifies a specific Rows instance.
ID string
CloseFunc func() error
NextFunc func(*driver.Row) error
OffsetFunc func() int64
TotalRowsFunc func() int64
UpdateSeqFunc func() string
}
var _ driver.Rows = &Rows{}
// Close calls r.CloseFunc
func (r *Rows) Close() error {
return r.CloseFunc()
}
// Next calls r.NextFunc
func (r *Rows) Next(row *driver.Row) error {
return r.NextFunc(row)
}
// Offset calls r.OffsetFunc
func (r *Rows) Offset() int64 {
return r.OffsetFunc()
}
// TotalRows calls r.TotalRowsFunc
func (r *Rows) TotalRows() int64 {
return r.TotalRowsFunc()
}
// UpdateSeq calls r.UpdateSeqFunc
func (r *Rows) UpdateSeq() string {
return r.UpdateSeqFunc()
}
// RowsWarner wraps driver.RowsWarner
type RowsWarner struct {
*Rows
WarningFunc func() string
}
var _ driver.RowsWarner = &RowsWarner{}
// Warning calls r.WarningFunc
func (r *RowsWarner) Warning() string {
return r.WarningFunc()
}
// Bookmarker wraps driver.Bookmarker
type Bookmarker struct {
*Rows
BookmarkFunc func() string
}
var _ driver.Bookmarker = &Bookmarker{}
// Bookmark calls r.BookmarkFunc
func (r *Bookmarker) Bookmark() string {
return r.BookmarkFunc()
}
// QueryIndexer provides driver.QueryIndexer.
type QueryIndexer struct {
*Rows
QueryIndexFunc func() int
}
var _ driver.QueryIndexer = &QueryIndexer{}
// QueryIndex calls r.QueryIndexFunc
func (r *QueryIndexer) QueryIndex() int {
return r.QueryIndexFunc()
}