introduced field_attributes shortcuts and added method on_base() to all processor classes
This commit is contained in:
+10
-10
@@ -13,8 +13,7 @@
|
||||
namespace demo {
|
||||
|
||||
struct recipe;
|
||||
struct ingredient
|
||||
{
|
||||
struct ingredient {
|
||||
unsigned int id{};
|
||||
std::string name;
|
||||
matador::object::collection<matador::object::object_ptr<demo::recipe>> recipes{};
|
||||
@@ -25,15 +24,15 @@ struct ingredient
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", matador::utils::fetch_type::Eager);
|
||||
field::attribute(op, "name", name, VarChar255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::CascadeAllFetchEager);
|
||||
}
|
||||
};
|
||||
|
||||
struct recipe
|
||||
{
|
||||
struct recipe {
|
||||
unsigned int id{};
|
||||
std::string name;
|
||||
matador::object::collection<matador::object::object_ptr<demo::ingredient>> ingredients{};
|
||||
@@ -44,10 +43,11 @@ struct recipe
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, matador::utils::fetch_type::Lazy);
|
||||
field::attribute(op, "name", name, VarChar255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::CascadeAllFetchLazy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user