#ifndef MATADOR_COUNTRY_HPP #define MATADOR_COUNTRY_HPP #include "matador/utils/access.hpp" #include "matador/object/object_ptr.hpp" #include namespace matador::test { template struct capital_pk_generator; template struct country_pk_generator { unsigned int id{}; std::string name; object::object_ptr> capital; country_pk_generator() = default; explicit country_pk_generator(std::string name) : name(std::move(name)) {} country_pk_generator(const unsigned int id, std::string name) : id(id) , name(std::move(name)) {} template void process(Operator &op) { namespace field = matador::access; using namespace matador::utils; field::primary_key(op, "id", id, PkAttribute); field::attribute(op, "name", name, UniqueVarChar255); field::has_one(op, "capital", capital, "country_id", CascadeAllFetchEager); } }; template struct capital_pk_generator { unsigned int id{}; std::string name; object::object_ptr> country; capital_pk_generator() = default; capital_pk_generator(std::string name, object::object_ptr> country) : name(std::move(name)) , country(std::move(country)) {} capital_pk_generator(const unsigned int id, std::string name, object::object_ptr> country) : id(id) , name(std::move(name)) , country(std::move(country)) {} template void process(Operator &op) { namespace field = matador::access; using namespace matador::utils; field::primary_key(op, "id", id, PkAttribute); field::attribute(op, "name", name, VarChar255); field::belongs_to(op, "country_id", country, CascadeAllFetchLazy); } }; using country = country_pk_generator; using country_identity = country_pk_generator; using country_sequence = country_pk_generator; using country_table = country_pk_generator; using capital = capital_pk_generator; using capital_identity = capital_pk_generator; using capital_sequence = capital_pk_generator; using capital_table = capital_pk_generator; } #endif //MATADOR_COUNTRY_HPP