added to many fields to entities author, book, recipe and ingredient

This commit is contained in:
2024-03-29 11:41:14 +01:00
parent 05c0c0393d
commit 6f3e589e10
3 changed files with 8 additions and 1 deletions
+5
View File
@@ -11,16 +11,19 @@
namespace matador::test {
struct recipe;
struct ingredient
{
unsigned long id{};
std::string name;
std::vector<matador::sql::entity<recipe>> recipes;
template<class Operator>
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);
}
};
@@ -28,12 +31,14 @@ struct recipe
{
unsigned long id{};
std::string name;
std::vector<matador::sql::entity<ingredient>> ingredients;
template<class Operator>
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);
}
};