introduced table repository
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#ifndef QUERY_AIRPLANE_HPP
|
||||
#define QUERY_AIRPLANE_HPP
|
||||
|
||||
#include "category.hpp"
|
||||
#include "supplier.hpp"
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/cascade_type.hpp"
|
||||
#include "matador/utils/field_attributes.hpp"
|
||||
|
||||
#include "matador/sql/foreign.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct airplane
|
||||
{
|
||||
unsigned long id;
|
||||
std::string brand;
|
||||
std::string model;
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::utils::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "brand", brand, 255);
|
||||
field::attribute(op, "model", model, 255);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //QUERY_AIRPLANE_HPP
|
||||
@@ -0,0 +1,33 @@
|
||||
#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/field_attributes.hpp"
|
||||
|
||||
#include "matador/sql/foreign.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct flight {
|
||||
unsigned long id;
|
||||
sql::foreign<test::airplane> airplane;
|
||||
std::string pilot_name;
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::utils::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::has_one(op, "airplane_id", airplane, utils::cascade_type::ALL);
|
||||
field::attribute(op, "pilot_name", pilot_name, 255);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //QUERY_FLIGHT_HPP
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef QUERY_PERSON_HPP
|
||||
#define QUERY_PERSON_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/field_attributes.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace matador::test {
|
||||
|
||||
struct person
|
||||
{
|
||||
unsigned long id{};
|
||||
std::string name;
|
||||
unsigned int age{};
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::utils::access;
|
||||
using namespace matador::utils;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::attribute(op, "age", age);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif //QUERY_PERSON_HPP
|
||||
Reference in New Issue
Block a user