-
Notifications
You must be signed in to change notification settings - Fork 16
/
models.go
51 lines (46 loc) · 2.13 KB
/
models.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
package data
import (
"errors"
"github.com/stellar/stellar-disbursement-platform-backend/db"
)
var (
ErrRecordNotFound = errors.New("record not found")
ErrRecordAlreadyExists = errors.New("record already exists")
ErrMismatchNumRowsAffected = errors.New("mismatch number of rows affected")
ErrMissingInput = errors.New("missing input")
)
type Models struct {
Disbursements *DisbursementModel
Wallets *WalletModel
Countries *CountryModel
Assets *AssetModel
Organizations *OrganizationModel
Payment *PaymentModel
Receiver *ReceiverModel
DisbursementInstructions *DisbursementInstructionModel
ReceiverVerification *ReceiverVerificationModel
ReceiverWallet *ReceiverWalletModel
DisbursementReceivers *DisbursementReceiverModel
Message *MessageModel
DBConnectionPool db.DBConnectionPool
}
func NewModels(dbConnectionPool db.DBConnectionPool) (*Models, error) {
if dbConnectionPool == nil {
return nil, errors.New("dbConnectionPool is required for NewModels")
}
return &Models{
Disbursements: &DisbursementModel{dbConnectionPool: dbConnectionPool},
Wallets: &WalletModel{dbConnectionPool: dbConnectionPool},
Countries: &CountryModel{dbConnectionPool: dbConnectionPool},
Assets: &AssetModel{dbConnectionPool: dbConnectionPool},
Organizations: &OrganizationModel{dbConnectionPool: dbConnectionPool},
Payment: &PaymentModel{dbConnectionPool: dbConnectionPool},
Receiver: &ReceiverModel{},
DisbursementInstructions: NewDisbursementInstructionModel(dbConnectionPool),
ReceiverVerification: &ReceiverVerificationModel{dbConnectionPool: dbConnectionPool},
ReceiverWallet: &ReceiverWalletModel{dbConnectionPool: dbConnectionPool},
DisbursementReceivers: &DisbursementReceiverModel{dbConnectionPool: dbConnectionPool},
Message: &MessageModel{dbConnectionPool: dbConnectionPool},
DBConnectionPool: dbConnectionPool,
}, nil
}