63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
#ifndef QUERY_ENTITY_QUERY_BUILDER_HPP
|
|
#define QUERY_ENTITY_QUERY_BUILDER_HPP
|
|
|
|
#include "matador/sql/query_context.hpp"
|
|
|
|
namespace matador::sql {
|
|
|
|
template < typename PrimaryKeyType >
|
|
class entity_query_builder
|
|
{
|
|
public:
|
|
// determine pk
|
|
// collect eager relations for joins
|
|
template<class EntityType>
|
|
query_context build() {
|
|
EntityType obj;
|
|
matador::utils::access::process(*this, obj);
|
|
return {};
|
|
}
|
|
|
|
template < class V >
|
|
void on_primary_key(const char *id, V &, typename std::enable_if<std::is_integral<V>::value && !std::is_same<bool, V>::value>::type* = 0)
|
|
{
|
|
}
|
|
|
|
void on_primary_key(const char *id, std::string &, size_t)
|
|
{
|
|
|
|
}
|
|
void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {}
|
|
|
|
template<typename Type>
|
|
void on_attribute(const char * /*id*/, Type &, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
|
|
|
template<class Pointer>
|
|
void on_belongs_to(const char *id, Pointer &, const utils::foreign_attributes &/*attr*/)
|
|
{
|
|
}
|
|
|
|
template<class Pointer>
|
|
void on_has_one(const char *id, Pointer &, const utils::foreign_attributes &attr)
|
|
{
|
|
|
|
}
|
|
|
|
template<class ContainerType>
|
|
void on_has_many(const char *, ContainerType &, const char *, const char *, const utils::foreign_attributes &attr)
|
|
{
|
|
}
|
|
|
|
template<class ContainerType>
|
|
void on_has_many(const char *id, ContainerType &c, const utils::foreign_attributes &attr)
|
|
{
|
|
on_has_many(id, c, "", "", attr);
|
|
}
|
|
|
|
private:
|
|
PrimaryKeyType pk_;
|
|
};
|
|
|
|
}
|
|
#endif //QUERY_ENTITY_QUERY_BUILDER_HPP
|