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 {
return json::array(); };
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.h:99
Rule addRule()
Definition tables.cpp:129
std::string tableName()
Definition tables.cpp:63
static std::pair< bool, std::string > requiredConstraintCheck(const json &field, const json &entity)
Definition tables_validation.cpp:174
json parseDbRowToJson(const soci::row &row) const
Definition tables_utils.cpp:66
Rule updateRule()
Definition tables.cpp:139
virtual void fetchRecords(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:229
Rule m_getRule
Definition tables.h:156
const std::string __class_name__
Definition tables.h:145
static std::pair< bool, std::string > minimumConstraintCheck(const json &field, const json &entity)
Definition tables_validation.cpp:112
static std::pair< bool, std::string > validatorConstraintCheck(const json &field, const json &entity)
Definition tables_validation.cpp:188
std::string getColTypeFromName(const std::string &col, const std::vector< json > &fields) const
Definition tables_utils.cpp:347
virtual bool setupRoutes()
Definition tables_routes.cpp:18
json checkValueInColumns(const std::string &value, const std::vector< std::string > &columns) const
Definition tables_utils.cpp:28
json update(const std::string &id, const json &entity, const json &opts) override
Definition tables_crud.cpp:166
void setTableName(const std::string &name)
Definition tables.cpp:68
Rule m_deleteRule
Definition tables.h:159
void setDeleteRule(const Rule &rule)
Definition tables.cpp:154
static bool getAuthToken(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:158
std::string m_routeName
Definition tables.h:150
Rule m_updateRule
Definition tables.h:158
Rule listRule()
Definition tables.cpp:109
std::optional< std::string > validateUpdateRequestBody(const json &body) const
Definition tables_validation.cpp:60
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:342
std::vector< json > m_fields
Definition tables.h:152
std::string m_tableId
Definition tables.h:148
static std::optional< json > validateTableSchema(const json &entity)
Definition tables_validation.cpp:229
void setAddRule(const Rule &rule)
Definition tables.cpp:134
void setIsSystemTable(bool isSystemTable)
Definition tables.cpp:104
json getValueFromType(const std::string &type, const std::string &value)
Definition tables_utils.cpp:171
std::string m_tableName
Definition tables.h:147
bool m_isSystem
Definition tables.h:151
std::string tableId()
Definition tables.cpp:73
virtual void deleteRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:992
bool recordExists(const std::string &id) const
Definition tables_utils.cpp:358
std::string tableType()
Definition tables.cpp:83
virtual void fetchRecord(const Request &req, Response &res, Context &ctx)
Definition tables_routes.cpp:163
void setGetRule(const Rule &rule)
Definition tables.cpp:124
virtual bool hasAccess(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:181
json create(const json &entity, const json &opts) override
Definition tables_crud.cpp:18
Rule m_listRule
Definition tables.h:155
void setFields(const std::vector< json > &fields)
Definition tables.cpp:93
static std::pair< bool, std::string > maximumConstraintCheck(const json &field, const json &entity)
Definition tables_validation.cpp:143
virtual void createRecord(const Request &req, Response &res, const ContentReader &reader, Context &ctx)
Definition tables_routes.cpp:299
static std::pair< bool, std::string > viewTypeSQLCheck(const json &entity)
Definition tables_validation.cpp:215
void setUpdateRule(const Rule &rule)
Definition tables.cpp:144
Rule m_addRule
Definition tables.h:157
std::optional< std::string > validateRequestBody(const json &body) const
Definition tables_validation.cpp:14
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:149
std::optional< json > bindEntityToSociValue(soci::values &vals, const json &entity) const
Helper function to bind json values to soci::values for use in soci::use(...) when executing SQL stat...
Definition tables_utils.cpp:201
std::optional< json > read(const std::string &id, const json &opts) override
Definition tables_crud.cpp:143
Rule deleteRule()
Definition tables.cpp:149
virtual void authWithEmailAndPassword(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:15
virtual void resetPassword(const Request &req, Response &res, Context &ctx)
Definition tables_auth.cpp:147
bool isSystem() const
Definition tables.cpp:99
std::optional< json > findFieldByKey(const std::string &key) const
Definition tables_utils.cpp:16
virtual void updateRecord(const Request &req, Response &res, const ContentReader &reader, Context &ctx)
Definition tables_routes.cpp:634
json list_records(const json &opts)
Definition tables_crud.cpp:432
void setTableId(const std::string &id)
Definition tables.cpp:78
bool remove(const std::string &id, const json &opts) override
Definition tables_crud.cpp:373
nlohmann::json json
Definition mantis.h:35
router.h
Definition app.h:31
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14
std::string Rule
Definition models.h:100
httplib::ContentReader ContentReader
Shorthand for httplib::ContentReader
Definition http.h:124
httplib::Response Response
Shorthand for httplib::Response
Definition http.h:121
httplib::Request Request
Shorthand for httplib::Request
Definition http.h:118