39 lines
942 B
C++
39 lines
942 B
C++
#ifndef QUERY_FLIGHT_HPP
|
|
#define QUERY_FLIGHT_HPP
|
|
|
|
#include "airplane.hpp"
|
|
|
|
#include "matador/utils/access.hpp"
|
|
#include "matador/utils/cascade_type.hpp"
|
|
#include "matador/utils/fetch_type.hpp"
|
|
|
|
#include "matador/object/object_ptr.hpp"
|
|
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
namespace matador::test {
|
|
|
|
struct flight {
|
|
flight() = default;
|
|
flight(const unsigned int id, const object::object_ptr<airplane> &plane, std::string name)
|
|
: id(id), plane(plane), pilot_name(std::move(name)) {}
|
|
|
|
unsigned int id{};
|
|
object::object_ptr<airplane> plane;
|
|
std::string pilot_name;
|
|
|
|
template<class Operator>
|
|
void process(Operator &op) {
|
|
namespace field = matador::access;
|
|
using namespace matador::utils;
|
|
field::primary_key(op, "id", id);
|
|
field::has_one(op, "airplane_id", plane, {utils::cascade_type::ALL, utils::fetch_type::EAGER});
|
|
field::attribute(op, "pilot_name", pilot_name, 255);
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif //QUERY_FLIGHT_HPP
|