This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
generated from mrz1836/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
action_draft_transaction.go
62 lines (48 loc) · 1.75 KB
/
action_draft_transaction.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
package bux
import (
"context"
"github.com/mrz1836/go-datastore"
)
// GetDraftTransactionByID will get a draft transaction from the Datastore
func (c *Client) GetDraftTransactionByID(ctx context.Context, id string, opts ...ModelOps) (*DraftTransaction, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_draft_transactions")
// Get the draft transactions
draftTransaction, err := getDraftTransactionID(
ctx, "", id, c.DefaultModelOptions(opts...)...,
)
if err != nil {
return nil, err
}
return draftTransaction, nil
}
// GetDraftTransactions will get all the draft transactions from the Datastore
func (c *Client) GetDraftTransactions(ctx context.Context, metadataConditions *Metadata,
conditions *map[string]interface{}, queryParams *datastore.QueryParams, opts ...ModelOps) ([]*DraftTransaction, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_draft_transactions")
// Get the draft transactions
draftTransactions, err := getDraftTransactions(
ctx, metadataConditions, conditions, queryParams,
c.DefaultModelOptions(opts...)...,
)
if err != nil {
return nil, err
}
return draftTransactions, nil
}
// GetDraftTransactionsCount will get a count of all the draft transactions from the Datastore
func (c *Client) GetDraftTransactionsCount(ctx context.Context, metadataConditions *Metadata,
conditions *map[string]interface{}, opts ...ModelOps) (int64, error) {
// Check for existing NewRelic transaction
ctx = c.GetOrStartTxn(ctx, "get_draft_transactions_count")
// Get the draft transactions count
count, err := getDraftTransactionsCount(
ctx, metadataConditions, conditions,
c.DefaultModelOptions(opts...)...,
)
if err != nil {
return 0, err
}
return count, nil
}