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

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

#include <country_repository.hpp>

Collaboration diagram for country_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::countryread_latest (context ctx, std::uint32_t offset, std::uint32_t limit)
 Reads latest countries with pagination support.
 
std::uint32_t get_total_country_count (context ctx)
 Gets the total count of active countries.
 
void remove (context ctx, const std::string &alpha2_code)
 Deletes a country by closing its temporal validity.
 
void write (context ctx, const domain::country &country)
 Writes countries to database. Expects the country set to have unique alpha-2 codes.
 
void write (context ctx, const std::vector< domain::country > &countries)
 
std::vector< domain::countryread_latest (context ctx)
 Reads latest countries, possibly filtered by alpha-2 code.
 
std::vector< domain::countryread_latest (context ctx, const std::string &alpha2_code)
 
std::vector< domain::countryread_at_timepoint (context ctx, const std::string &as_of)
 Reads countries at the supplied time point, possibly filtered by alpha-2 code.
 
std::vector< domain::countryread_at_timepoint (context ctx, const std::string &as_of, const std::string &alpha2_code)
 
std::vector< domain::countryread_all (context ctx)
 Reads all countries, possibly filtered by alpha-2 code.
 
std::vector< domain::countryread_all (context ctx, const std::string &alpha2_code)
 

Detailed Description

Reads and writes countries off of data storage.

Member Function Documentation

◆ read_latest()

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

Reads latest countries with pagination support.

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

◆ get_total_country_count()

std::uint32_t get_total_country_count ( context  ctx)

Gets the total count of active countries.

Parameters
ctxRepository context with database connection
Returns
Total number of countries with valid_to == max_timestamp
Here is the caller graph for this function:

◆ remove()

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

Deletes a country by closing its temporal validity.

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

Here is the caller graph for this function: