9#include <nlohmann/json.hpp>
11#include "../models/models.h"
13#include "../crud/crud.h"
15#include "../../app/app.h"
19 using json = nlohmann::json;
71 std::vector<json>
fields()
const;
96 std::optional<json>
read(
const std::string&
id,
const json& opts)
override;
98 bool remove(
const std::string&
id,
const json& opts)
override;
99 std::vector<json>
list(
const json& opts)
override;
Class to model the behaviour of a table in database.
Definition tables.h:31
Rule getRule()
Definition tables.cpp:119
std::vector< json > list(const json &opts) override
Definition tables_crud.cpp:613
virtual void updateRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:334
Rule addRule()
Definition tables.cpp:129
std::string tableName()
Definition tables.cpp:63
json parseDbRowToJson(const soci::row &row) const
Definition tables_utils.cpp:64
std::optional< json > validateRequestBody(const json &body) const
Definition tables_validation.cpp:14
Rule updateRule()
Definition tables.cpp:139
virtual void fetchRecords(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:224
Rule m_getRule
Definition tables.h:122
const std::string __class_name__
Definition tables.h:111
std::string getColTypeFromName(const std::string &col, const std::vector< json > &fields) const
Definition tables_utils.cpp:160
virtual bool setupRoutes()
Definition tables_routes.cpp:14
json checkValueInColumns(const std::string &value, const std::vector< std::string > &columns) const
Definition tables_utils.cpp:26
json update(const std::string &id, const json &entity, const json &opts) override
Definition tables_crud.cpp:315
void setTableName(const std::string &name)
Definition tables.cpp:68
Rule m_deleteRule
Definition tables.h:125
void setDeleteRule(const Rule &rule)
Definition tables.cpp:154
static bool getAuthToken(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:162
std::string m_routeName
Definition tables.h:116
Rule m_updateRule
Definition tables.h:124
Rule listRule()
Definition tables.cpp:109
std::vector< json > fields() const
Definition tables.cpp:88
void fromJson(const json &j)
Definition tables.cpp:32
virtual ~TableUnit() override=default
static std::string generateTableId(const std::string &tablename)
Definition tables_utils.cpp:155
std::vector< json > m_fields
Definition tables.h:118
std::string m_tableId
Definition tables.h:114
void setAddRule(const Rule &rule)
Definition tables.cpp:134
void setIsSystemTable(bool isSystemTable)
Definition tables.cpp:104
std::string m_tableName
Definition tables.h:113
bool m_isSystem
Definition tables.h:117
std::string tableId()
Definition tables.cpp:73
virtual void deleteRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:433
bool recordExists(const std::string &id) const
Definition tables_utils.cpp:172
std::string tableType()
Definition tables.cpp:83
virtual void fetchRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:158
void setGetRule(const Rule &rule)
Definition tables.cpp:124
virtual bool hasAccess(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:188
json create(const json &entity, const json &opts) override
Definition tables_crud.cpp:14
Rule m_listRule
Definition tables.h:121
void setFields(const std::vector< json > &fields)
Definition tables.cpp:93
void setUpdateRule(const Rule &rule)
Definition tables.cpp:144
virtual void createRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:262
Rule m_addRule
Definition tables.h:123
void setListRule(const Rule &rule)
Definition tables.cpp:114
void setRouteDisplayName(const std::string &routeName)
Definition tables.cpp:55
std::string m_tableType
Definition tables.h:115
std::optional< json > read(const std::string &id, const json &opts) override
Definition tables_crud.cpp:292
Rule deleteRule()
Definition tables.cpp:149
virtual void authWithEmailAndPassword(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:14
virtual void resetPassword(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:153
bool isSystem() const
Definition tables.cpp:99
std::optional< json > validateUpdateRequestBody(const json &body) const
Definition tables_validation.cpp:164
std::optional< json > findFieldByKey(const std::string &key) const
Definition tables_utils.cpp:14
void setTableId(const std::string &id)
Definition tables.cpp:78
bool remove(const std::string &id, const json &opts) override
Definition tables_crud.cpp:586
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:30
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14
std::string Rule
Definition models.h:96
httplib::Response Response
Shorthand for httplib::Response
Definition http.h:121
httplib::Request Request
Shorthand for httplib::Request
Definition http.h:118