forked from stellar/go
/
operation_participant_batch_insert_builder.go
45 lines (39 loc) · 1.24 KB
/
operation_participant_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
package history
import (
"github.com/aiblocks/go/support/db"
)
// OperationParticipantBatchInsertBuilder is used to insert a transaction's operations into the
// history_operations table
type OperationParticipantBatchInsertBuilder interface {
Add(
operationID int64,
accountID int64,
) error
Exec() error
}
// operationParticipantBatchInsertBuilder is a simple wrapper around db.BatchInsertBuilder
type operationParticipantBatchInsertBuilder struct {
builder db.BatchInsertBuilder
}
// NewOperationParticipantBatchInsertBuilder constructs a new TransactionBatchInsertBuilder instance
func (q *Q) NewOperationParticipantBatchInsertBuilder(maxBatchSize int) OperationParticipantBatchInsertBuilder {
return &operationParticipantBatchInsertBuilder{
builder: db.BatchInsertBuilder{
Table: q.GetTable("history_operation_participants"),
MaxBatchSize: maxBatchSize,
},
}
}
// Add adds an operation participant to the batch
func (i *operationParticipantBatchInsertBuilder) Add(
operationID int64,
accountID int64,
) error {
return i.builder.Row(map[string]interface{}{
"history_operation_id": operationID,
"history_account_id": accountID,
})
}
func (i *operationParticipantBatchInsertBuilder) Exec() error {
return i.builder.Exec()
}