27 lines
690 B
C++
27 lines
690 B
C++
#ifndef BOOK_HPP
|
|
#define BOOK_HPP
|
|
|
|
#include "matador/object/object_ptr.hpp"
|
|
#include "matador/utils/access.hpp"
|
|
|
|
namespace demo {
|
|
struct author;
|
|
|
|
struct book {
|
|
unsigned int id{};
|
|
matador::object::object_ptr<author> book_author;
|
|
std::string title;
|
|
unsigned short published_in{};
|
|
|
|
template<typename Operator>
|
|
void process( Operator& op ) {
|
|
namespace field = matador::access;
|
|
field::primary_key( op, "id", id );
|
|
field::attribute( op, "title", title, 511 );
|
|
field::belongs_to( op, "author_id", book_author, matador::utils::CascadeNoneFetchLazy );
|
|
field::attribute( op, "published_in", published_in );
|
|
}
|
|
};
|
|
}
|
|
#endif //BOOK_HPP
|