#ifndef QUERY_RECIPE_HPP #define QUERY_RECIPE_HPP #include "matador/utils/access.hpp" #include "matador/utils/field_attributes.hpp" #include "matador/utils/foreign_attributes.hpp" #include "matador/sql/entity.hpp" #include namespace matador::test { struct recipe; struct ingredient { unsigned long id{}; std::string name; std::vector> recipes; template void process(Operator &op) { namespace field = matador::utils::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); field::has_many(op, "recipes", recipes, "ingredient_id", "recipe_id", utils::fetch_type::EAGER); } }; struct recipe { unsigned long id{}; std::string name; std::vector> ingredients; template void process(Operator &op) { namespace field = matador::utils::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, 255); field::has_many(op, "ingredients", ingredients, "recipe_id", "ingredient_id", utils::fetch_type::EAGER); } }; struct recipe_ingredient { sql::entity recipe_; sql::entity ingredient_; template void process(Operator &op) { namespace field = matador::utils::access; field::belongs_to(op, "recipe_id", recipe_, utils::default_foreign_attributes); field::belongs_to(op, "ingredient_id", ingredient_, utils::default_foreign_attributes); } }; } #endif //QUERY_RECIPE_HPP