|
| | MbEntity (const MantisBase &app, const nlohmann::json &schema) |
| | Construct entity from schema JSON object, bound to its app.
|
| | MbEntity (const MantisBase &app, const std::string &name, const std::string &type) |
| | Construct entity with name and type, bound to its app.
|
| | MbEntity (const MbEntity &)=default |
| | MbEntity (MbEntity &&)=default |
| std::string | id () const |
| | Get entity unique identifier.
|
| std::string | name () const |
| | Get entity table name.
|
| std::string | type () const |
| | Get entity type ("base", "auth", or "view").
|
| bool | isSystem () const |
| | Check if entity is a system table.
|
| bool | hasApi () const |
| | Check if entity has API endpoints enabled.
|
| MbAuthMethods | authMethods () const |
| | Login methods for an auth entity.
|
| std::string | authMethodDisabledReason (std::string_view method) const |
| | Empty when method is enabled, otherwise the client-facing reason.
|
| std::string | viewQuery () const |
| | Get SQL query for view type entities.
|
| const std::vector< json > & | fields () const |
| | Get all field definitions.
|
| std::optional< json > | field (const std::string &field_name) const |
| | Get field definition by name.
|
| std::optional< json > | hasField (const std::string &field_name) const |
| | Check if field exists by name.
|
| const json & | rules () const |
| | Get all access rules.
|
| MbAccessRule | listRule () const |
| | Get list access rule (for GET /api/v1/entities/{table}).
|
| MbAccessRule | getRule () const |
| | Get read access rule (for GET /api/v1/entities/{table}/:id).
|
| MbAccessRule | addRule () const |
| | Get create access rule (for POST /api/v1/entities/{table}).
|
| MbAccessRule | updateRule () const |
| | Get update access rule (for PATCH /api/v1/entities/{table}/:id).
|
| MbAccessRule | deleteRule () const |
| | Get delete access rule (for DELETE /api/v1/entities/{table}/:id).
|
| Record | create (const json &record, const json &opts=json::object()) const |
| | Create a new record in the entity table.
|
| EntityListPage | listPage (const json &opts=json::object()) const |
| | List entity records with cursor pagination (always ordered by id ASC).
|
| Records | list (const json &opts=json::object()) const |
| | List records (items only; see listPage for pagination metadata).
|
| std::optional< Record > | read (const std::string &id, const json &opts=json::object()) const |
| | Read a single record by ID.
|
| Record | update (const std::string &id, const json &data, const json &opts=json::object()) const |
| | Update an existing record by ID.
|
| void | remove (const std::string &id) const |
| | Delete a record by ID.
|
| const json & | schema () const |
| | Get complete entity schema JSON.
|
| int | countRecords (const json &filter=json::object()) const |
| | Count records in the entity table, optionally matching a filter.
|
| bool | isEmpty () const |
| | Check if entity table is empty.
|
| bool | recordExists (const std::string &id) const |
| | Check if a record exists by ID.
|
| std::optional< json > | findField (const std::string &field_name) const |
| | Find field definition by name (alias for field()).
|
| std::optional< json > | queryFromCols (const std::string &value, const std::vector< std::string > &columns) const |
| | Query records by searching across multiple columns.
|
| | MbAppMixin (const MantisBase &app) |
| | Constrictor for instantiating this interface.
|
| | MbAppMixin (MbAppMixin &&)=default |
| MbAppMixin & | operator= (MbAppMixin &&)=delete |
| | MbAppMixin (const MbAppMixin &)=default |
| MbAppMixin & | operator= (const MbAppMixin &)=delete |
| const MantisBase & | mbApp () const |
| | Application that owns this service or request context.
|
| const MbLogger & | logger () const |
Represents a database table/entity with schema and CRUD operations.
MbEntity provides methods to interact with database tables including creating, reading, updating, and deleting records. It encapsulates schema information and access rules.
json schema = {{
"name",
"users"}, {
"type",
"base"}, {
"fields", json::array()}};
static std::unique_ptr< MantisBase > create(int argc, char **argv)
Create class instance given cmd args passed in.
Definition mantisbase.cpp:75
const json & schema() const
Get complete entity schema JSON.
Definition entity.cpp:176
MbEntity(const MantisBase &app, const nlohmann::json &schema)
Construct entity from schema JSON object, bound to its app.
Definition entity.cpp:8
nlohmann::json json
Shorten JSON namespace.
Definition api_keys.h:36