Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend represents the instance which manages the database.
func New ¶
New returns a new backend struct mainly containing a database connection, according to the read config file.
func (*Backend) SaveTransaction ¶
func (b *Backend) SaveTransaction(accountID uuid.UUID, amount int64, description string, currency string) (*Transaction, error)
SaveTransaction adds a new transaction to the database. It returns some data about the inserted transaction.
func (*Backend) UpdateTransaction ¶
func (b *Backend) UpdateTransaction(transactionID uuid.UUID, accountID uuid.UUID, amount int64) (*UpdatedTransaction, error)
UpdateTransaction updates the transaction corresponding to the given UUID. It returns the previous transaction account id and amount.
type Config ¶
type Config struct { // DBName is the database name DBName string `json:"db_name"` // User is the database user User string `json:"user"` // Password is the database password for the used user Password string `json:"password"` // Addr is the database address Addr string `json:"addr"` // Port is the database port Port int `json:"port"` // SkipVerify is a bool which determines if the backend // must skips the ssl mode or not. SkipVerify bool `json:"skip_verify,omitempty"` // contains filtered or unexported fields }
Config is the backend configuration.
type Transaction ¶
type Transaction struct { // ID is the transaction ID. ID uuid.UUID `json:"id" description:"Transaction ID"` // Account is the id of the account targeted by the transaction. AccountID uuid.UUID `json:"account_id" description:"Targeted Account ID"` // Amount is the transaction amount. Amount int64 `json:"amount" description:"Transaction amount"` // CreatedAt is the transaction creation date. CreatedAt time.Time `json:"created_at" description:"Transaction creation date"` }
Transaction represents a transaction.
type UpdatedTransaction ¶
type UpdatedTransaction struct { // ID is the transaction ID. ID uuid.UUID `json:"id" description:"Transaction ID"` // Previous is the pre-update transaction. Previous *Transaction `json:"previous" description:"Previous transaction replaced during the update"` // New is the post-update transaction. New *Transaction `json:"new" description:"New transaction inserted during the update"` }
UpdatedTransaction reprends a transaction update.
Click to show internal directories.
Click to hide internal directories.