#ifndef QUERY_STUDENT_HPP #define QUERY_STUDENT_HPP #include "matador/utils/access.hpp" #include "matador/utils/field_attributes.hpp" #include "matador/utils/foreign_attributes.hpp" #include "matador/object/object_ptr.hpp" #include "matador/object/collection.hpp" #include #include namespace matador::test { struct course; struct student { unsigned int id{}; std::string name; object::collection > courses; student() = default; explicit student(unsigned int id, std::string name) : id(id) , name(std::move(name)) { } template void process(Operator &op) { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "name", name, UniqueVarChar255); field::has_many_to_many(op, "student_courses", courses, "student_id", "course_id", utils::CascadeAllFetchLazy); } }; struct course { unsigned int id{}; std::string title; object::collection > students; course() = default; explicit course(unsigned int id, std::string title) : id(id) , title(std::move(title)) { } template void process(Operator &op) { namespace field = matador::access; field::primary_key(op, "id", id); field::attribute(op, "title", title, UniqueVarChar255); field::has_many_to_many(op, "student_courses", students, utils::CascadeAllFetchEager); } }; } #endif //QUERY_STUDENT_HPP