-
Notifications
You must be signed in to change notification settings - Fork 0
/
claimable_balance_claimant_batch_insert_builder.go
46 lines (38 loc) · 1.5 KB
/
claimable_balance_claimant_batch_insert_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
package history
import (
"context"
"github.com/shantanu-hashcash/go/support/db"
)
// ClaimableBalanceClaimantBatchInsertBuilder is used to insert claimants into the
// claimable_balance_claimants table
type ClaimableBalanceClaimantBatchInsertBuilder interface {
Add(claimableBalanceClaimant ClaimableBalanceClaimant) error
Exec(ctx context.Context) error
Len() int
}
// ClaimableBalanceClaimantBatchInsertBuilder is a simple wrapper around db.FastBatchInsertBuilder
type claimableBalanceClaimantBatchInsertBuilder struct {
session db.SessionInterface
builder db.FastBatchInsertBuilder
table string
}
// NewClaimableBalanceClaimantBatchInsertBuilder constructs a new ClaimableBalanceClaimantBatchInsertBuilder instance
func (q *Q) NewClaimableBalanceClaimantBatchInsertBuilder() ClaimableBalanceClaimantBatchInsertBuilder {
return &claimableBalanceClaimantBatchInsertBuilder{
session: q,
builder: db.FastBatchInsertBuilder{},
table: "claimable_balance_claimants",
}
}
// Add adds a new claimant to the batch
func (i *claimableBalanceClaimantBatchInsertBuilder) Add(claimableBalanceClaimant ClaimableBalanceClaimant) error {
return i.builder.RowStruct(claimableBalanceClaimant)
}
// Exec writes the batch of claimants to the database.
func (i *claimableBalanceClaimantBatchInsertBuilder) Exec(ctx context.Context) error {
return i.builder.Exec(ctx, i.session, i.table)
}
// Len returns the number of items in the batch.
func (i *claimableBalanceClaimantBatchInsertBuilder) Len() int {
return i.builder.Len()
}