/
operation_participant_batch_insert_builder.go
49 lines (42 loc) · 1.35 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
46
47
48
49
package history
import (
"context"
"github.com/TosinShada/monorepo/support/db"
)
// OperationParticipantBatchInsertBuilder is used to insert a transaction's operations into the
// history_operations table
type OperationParticipantBatchInsertBuilder interface {
Add(
ctx context.Context,
operationID int64,
accountID int64,
) error
Exec(ctx context.Context) 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(
ctx context.Context,
operationID int64,
accountID int64,
) error {
return i.builder.Row(ctx, map[string]interface{}{
"history_operation_id": operationID,
"history_account_id": accountID,
})
}
func (i *operationParticipantBatchInsertBuilder) Exec(ctx context.Context) error {
return i.builder.Exec(ctx)
}