Mantis App v0.1.13
Loading...
Searching...
No Matches
sys_tables.h
Go to the documentation of this file.
1//
2// Created by allan on 20/05/2025.
3//
4
5#ifndef SYS_TABLES_H
6#define SYS_TABLES_H
7
8#include "tables.h"
9
10
11namespace mantis
12{
13#define DUMP_RESPONSE() Log::trace("DUMP_RESPONSE: {}", response.dump())
14
15 class TablesCrud;
16
23 class SysTablesUnit final : public TableUnit
24 {
25 public:
26 SysTablesUnit(const std::string& tableName,
27 const std::string& tableId,
28 const std::string& tableType = "auth");
29 ~SysTablesUnit() override = default;
30
31 bool setupRoutes() override;
32
33 void fetchRecord(const Request& req, Response& res, Context& ctx) override;
34 void fetchRecords(const Request& req, Response& res, Context& ctx) override;
35 void createRecord(const Request& req, Response& res, Context& ctx) override;
36 void updateRecord(const Request& req, Response& res, Context& ctx) override;
37 void deleteRecord(const Request& req, Response& res, Context& ctx) override;
38
39 // Auth Routes Handlers
40 void authWithEmailAndPassword(const Request& req, Response& res, Context& ctx) override;
41 bool hasAccess(const Request& req, Response& res, Context& ctx) override;
42
43 json create(const json& entity, const json& opts) override;
44 std::optional<json> read(const std::string& id, const json& opts) override;
45 json update(const std::string& id, const json& entity, const json& opts) override;
46 bool remove(const std::string& id, const json& opts) override;
47 std::vector<json> list(const json& opts) override;
48
49 private:
50 bool itemExists(const std::string& tableName, const std::string& id) const;
51 };
52} // mantis
53
54#endif //SYS_TABLES_H
Definition http.h:59
Class to manage tables metadata like access rules, name, etc.
Definition sys_tables.h:24
bool setupRoutes() override
Definition sys_tables.cpp:22
std::optional< json > read(const std::string &id, const json &opts) override
Definition sys_tables_crud.cpp:238
void authWithEmailAndPassword(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:515
bool hasAccess(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:659
void updateRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:392
bool remove(const std::string &id, const json &opts) override
Definition sys_tables_crud.cpp:698
json create(const json &entity, const json &opts) override
Definition sys_tables_crud.cpp:23
void deleteRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:471
void fetchRecords(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:222
void createRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:258
std::vector< json > list(const json &opts) override
Definition sys_tables_crud.cpp:733
void fetchRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:158
~SysTablesUnit() override=default
json update(const std::string &id, const json &entity, const json &opts) override
Definition sys_tables_crud.cpp:265
Class to model the behaviour of a table in database.
Definition tables.h:31
std::string tableName()
Definition tables.cpp:63
std::string tableId()
Definition tables.cpp:73
std::string tableType()
Definition tables.cpp:83
router.h
Definition app.h:30
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14
httplib::Response Response
‍Shorthand for httplib::Response
Definition http.h:121
httplib::Request Request
‍Shorthand for httplib::Request
Definition http.h:118