implemented lazy loading for object_ptr and belongs_to
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "supplier.hpp"
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/cascade_type.hpp"
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
|
||||
@@ -14,8 +13,8 @@
|
||||
namespace matador::test {
|
||||
struct product {
|
||||
std::string product_name;
|
||||
object::object_ptr<supplier> supplier;
|
||||
object::object_ptr<category> category;
|
||||
object::object_ptr<supplier> seller;
|
||||
object::object_ptr<category> type;
|
||||
std::string quantity_per_unit;
|
||||
unsigned int unit_price;
|
||||
unsigned int units_in_stock;
|
||||
@@ -28,8 +27,8 @@ struct product {
|
||||
namespace field = matador::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "product_name", product_name, 255);
|
||||
field::belongs_to(op, "supplier_id", supplier, CascadeAllFetchLazy);
|
||||
field::belongs_to(op, "category_id", category, CascadeAllFetchLazy);
|
||||
field::belongs_to(op, "supplier_id", seller, CascadeAllFetchLazy);
|
||||
field::belongs_to(op, "category_id", type, CascadeAllFetchLazy);
|
||||
field::attribute(op, "quantity_per_unit", quantity_per_unit, 255);
|
||||
field::attribute(op, "unit_price", unit_price);
|
||||
field::attribute(op, "units_in_stock", units_in_stock);
|
||||
|
||||
Reference in New Issue
Block a user