ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
currency_repository Class Reference

Reads and writes currencies off of data storage. More...

#include <currency_repository.hpp>

Collaboration diagram for currency_repository:
Collaboration graph

Public Types

using context = ores::database::context
 

Public Member Functions

std::string sql ()
 Returns the SQL created by sqlgen to construct the table.
 
std::vector< domain::currencyread_latest (context ctx, std::uint32_t offset, std::uint32_t limit)
 Reads latest currencies with pagination support.
 
std::uint32_t get_total_currency_count (context ctx)
 Gets the total count of active currencies.
 
void remove (context ctx, const std::string &iso_code)
 Deletes a currency by closing its temporal validity.
 
void write (context ctx, const domain::currency &currencies)
 Writes currencies to database. Expects the currency set to have unique ISO codes.
 
void write (context ctx, const std::vector< domain::currency > &currencies)
 
std::vector< domain::currencyread_latest (context ctx)
 Reads latest currencies, possibly filtered by ISO code.
 
std::vector< domain::currencyread_latest (context ctx, const std::string &iso_code)
 
std::vector< domain::currencyread_at_timepoint (context ctx, const std::string &as_of)
 Reads currencies at the supplied time point, possibly filtered by ISO code.
 
std::vector< domain::currencyread_at_timepoint (context ctx, const std::string &as_of, const std::string &iso_code)
 
std::vector< domain::currencyread_all (context ctx)
 Reads all currencies, possibly filtered by ISO code.
 
std::vector< domain::currencyread_all (context ctx, const std::string &iso_code)
 

Detailed Description

Reads and writes currencies off of data storage.

Member Function Documentation

◆ read_latest()

std::vector< domain::currency > read_latest ( context  ctx,
std::uint32_t  offset,
std::uint32_t  limit 
)

Reads latest currencies with pagination support.

Parameters
ctxRepository context with database connection
offsetNumber of records to skip
limitMaximum number of records to return
Returns
Vector of currencies within the specified range

◆ get_total_currency_count()

std::uint32_t get_total_currency_count ( context  ctx)

Gets the total count of active currencies.

Parameters
ctxRepository context with database connection
Returns
Total number of currencies with valid_to == max_timestamp

◆ remove()

void remove ( context  ctx,
const std::string &  iso_code 
)

Deletes a currency by closing its temporal validity.

Sets the valid_to timestamp to now, effectively "deleting" the currency from the current point in time onwards while preserving history.