Documentation ¶
Index ¶
- func CreateIndexOnTransactionField(ctx context.Context, indexData []mongo.IndexModel) error
- func DeleteAccount(ctx context.Context, accountID string) error
- func DeleteTransaction(ctx context.Context, transactionID primitive.ObjectID) error
- func GetAccountBalances(ctx context.Context) (map[string]float64, error)
- func GetTransaction(ctx context.Context, transactionID primitive.ObjectID) (*models.TransactionDTO, error)
- func InsertAccount(ctx context.Context, account *models.AccountDTO) error
- func InsertTransaction(ctx context.Context, transaction *models.TransactionDTO) (interface{}, error)
- func IsAccountExists(ctx context.Context, accountID string) (bool, error)
- func IsAccountUsed(ctx context.Context, accountID string) (bool, error)
- func ListAccounts(ctx context.Context) ([]*models.AccountDTO, error)
- func ListTransactions(ctx context.Context, params *ListTransactionsParams) ([]*models.TransactionDTO, int, error)
- func UpdateAccount(ctx context.Context, accountID string, updates map[string]interface{}) error
- func UpdateTransaction(ctx context.Context, transactionID primitive.ObjectID, ...) error
- type ListTransactionsParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateIndexOnTransactionField ¶
func CreateIndexOnTransactionField(ctx context.Context, indexData []mongo.IndexModel) error
CreateIndexOnTransactionField creates a B-Tree index on the specified field in the transaction collection.
func DeleteAccount ¶
DeleteAccount deletes an account in the database.
func DeleteTransaction ¶
DeleteTransaction deletes a transaction from the database.
func GetAccountBalances ¶
GetAccountBalances provides a map of account IDs to their balance.
func GetTransaction ¶
func GetTransaction(ctx context.Context, transactionID primitive.ObjectID) (*models.TransactionDTO, error)
GetTransaction returns the transaction record matching the provided ID.
func InsertAccount ¶
func InsertAccount(ctx context.Context, account *models.AccountDTO) error
InsertAccount creates a new account in the database.
func InsertTransaction ¶
func InsertTransaction(ctx context.Context, transaction *models.TransactionDTO) (interface{}, error)
InsertTransaction creates a new transaction in the database. It returns the ID of the inserted document as well as the error if any.
func IsAccountExists ¶
IsAccountExists returns true if the account with the provided ID exists.
func IsAccountUsed ¶
IsAccountUsed returns true if even a single transaction is using the provided account, otherwise it returns false.
func ListAccounts ¶
func ListAccounts(ctx context.Context) ([]*models.AccountDTO, error)
ListAccounts provides a list of all accounts.
func ListTransactions ¶
func ListTransactions(ctx context.Context, params *ListTransactionsParams) ([]*models.TransactionDTO, int, error)
ListTransactions lists all the transactions that match the provided filter, pagination and sort params.
func UpdateAccount ¶
UpdateAccount updates an account in the database.
Types ¶
type ListTransactionsParams ¶
type ListTransactionsParams struct { // Filter is the search filter for the transactions. Filter map[string]interface{} // RequiredFields is the list of fields to be included in the response. RequiredFields []string // PaginationLimit is the max amount of transactions in the response. PaginationLimit int // PaginationSkip is the initial offset of the list. PaginationSkip int // SortField is the name of the field by which the transactions will be sorted. SortField string // SortOrder is the order of sorting. SortOrder int // ExcludeCount is a flag to control whether the total count of the transaction should also be calculated or not. ExcludeCount bool }
ListTransactionsParams is the schema of params required by the ListTransactions operation.