forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_builder.go
63 lines (55 loc) · 1.62 KB
/
get_builder.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
package db
import (
"github.com/stellar/go/support/errors"
)
// Exec executes the query represented by the builder, populating the
// destination with the results returned by running the query against the
// current database session.
func (gb *GetBuilder) Exec() error {
err := gb.Table.Session.Get(gb.dest, gb.sql)
if err != nil {
return errors.Wrap(err, "get failed")
}
return nil
}
// Offset is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#SelectBuilder.Offset
func (gb *GetBuilder) Offset(offset uint64) *GetBuilder {
gb.sql = gb.sql.Offset(offset)
return gb
}
// OrderBy is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#SelectBuilder.OrderBy
func (gb *GetBuilder) OrderBy(
orderBys ...string,
) *GetBuilder {
gb.sql = gb.sql.OrderBy(orderBys...)
return gb
}
// Prefix is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#SelectBuilder.Prefix
func (gb *GetBuilder) Prefix(
sql string,
args ...interface{},
) *GetBuilder {
gb.sql = gb.sql.Prefix(sql, args...)
return gb
}
// Suffix is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#SelectBuilder.Suffix
func (gb *GetBuilder) Suffix(
sql string,
args ...interface{},
) *GetBuilder {
gb.sql = gb.sql.Suffix(sql, args...)
return gb
}
// Where is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#GetBuilder.Where
func (gb *GetBuilder) Where(
pred interface{},
args ...interface{},
) *GetBuilder {
gb.sql = gb.sql.Where(pred, args...)
return gb
}