Mantis App v0.2.8
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 class TablesCrud;
14
21 class SysTablesUnit final : public TableUnit
22 {
23 public:
24 SysTablesUnit(const std::string& tableName,
25 const std::string& tableId,
26 const std::string& tableType = "auth");
27 ~SysTablesUnit() override = default;
28
29 bool setupRoutes() override;
30
31 void fetchRecord(const Request& req, Response& res, Context& ctx) override;
32 void fetchRecords(const Request& req, Response& res, Context& ctx) override;
33 void createRecord(const Request& req, Response& res, const ContentReader& reader, Context& ctx) override;
34 void updateRecord(const Request& req, Response& res, const ContentReader& reader, Context& ctx) override;
35 void deleteRecord(const Request& req, Response& res, Context& ctx) override;
36
37 // Auth Routes Handlers
38 void authWithEmailAndPassword(const Request& req, Response& res, Context& ctx) override;
39 bool hasAccess(const Request& req, Response& res, Context& ctx) override;
40
41 json create(const json& entity, const json& opts) override;
42 std::optional<json> read(const std::string& id, const json& opts) override;
43 json update(const std::string& id, const json& entity, const json& opts) override;
44 bool remove(const std::string& id, const json& opts) override;
45 std::vector<json> list(const json& opts) override;
46
47 private:
48 bool itemExists(const std::string& tableName, const std::string& id) const;
49 };
50} // mantis
51
52#endif //SYS_TABLES_H
Definition http.h:59
Class to manage tables metadata like access rules, name, etc.
Definition sys_tables.h:22
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:240
void authWithEmailAndPassword(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:465
bool hasAccess(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:602
bool remove(const std::string &id, const json &opts) override
Definition sys_tables_crud.cpp:703
json create(const json &entity, const json &opts) override
Definition sys_tables_crud.cpp:22
void deleteRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:419
void fetchRecords(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:227
void updateRecord(const Request &req, Response &res, const ContentReader &reader, Context &ctx) override
Definition sys_tables.cpp:331
std::vector< json > list(const json &opts) override
Definition sys_tables_crud.cpp:741
void fetchRecord(const Request &req, Response &res, Context &ctx) override
Definition sys_tables.cpp:161
~SysTablesUnit() override=default
void createRecord(const Request &req, Response &res, const ContentReader &reader, Context &ctx) override
Definition sys_tables.cpp:265
json update(const std::string &id, const json &entity, const json &opts) override
Definition sys_tables_crud.cpp:267
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:31
nlohmann::json json
Shorten JSON namespace.
Definition crud.h:14
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