![]() |
MantisBase v0.4.9
|
#include <entity_schema_field.h>
Public Member Functions | |
| MbEntitySchemaField (std::string field_name, std::string field_type) | |
| MbEntitySchemaField (const nlohmann::json &field_schema) | |
| Construct field from JSON schema object. | |
| MbEntitySchemaField (const MbEntitySchemaField &other) | |
| bool | operator== (const MbEntitySchemaField &other) const |
| std::string | id () const |
| Get field unique identifier. | |
| std::string | name () const |
| Get field name. | |
| MbEntitySchemaField & | setName (const std::string &name) |
| Set field name (fluent interface). | |
| std::string | type () const |
| Get field type. | |
| MbEntitySchemaField & | setType (const std::string &type) |
| MbIntPrecision | intPrecision () const |
| MbEntitySchemaField & | setIntPrecision (MbIntPrecision precision) |
| MbEntitySchemaField & | setPrecision (const std::string &precision) |
| bool | required () const |
| Check if field is required. | |
| MbEntitySchemaField & | setRequired (bool required) |
| Set required flag (fluent interface). | |
| bool | isPrimaryKey () const |
| Check if field is primary key. | |
| MbEntitySchemaField & | setIsPrimaryKey (bool pk) |
| Set primary key flag (fluent interface). | |
| bool | isSystem () const |
| Check if field is system field. | |
| MbEntitySchemaField & | setIsSystem (bool system) |
| Set system field flag (fluent interface). | |
| bool | isUnique () const |
| Check if field has unique constraint. | |
| MbEntitySchemaField & | setIsUnique (bool unique) |
| Set unique constraint (fluent interface). | |
| bool | isForeignKey () const |
| Check if field is a foreign key. | |
| std::string | foreignKeyTable () const |
| Get foreign key reference table name. | |
| std::string | foreignKeyColumn () const |
| Get foreign key reference column name. | |
| std::string | foreignKeyOnUpdate () const |
| Get foreign key update policy. | |
| std::string | foreignKeyOnDelete () const |
| Get foreign key delete policy. | |
| MbEntitySchemaField & | setForeignKey (const std::string &table, const std::string &column="id", const std::string &onUpdate="RESTRICT", const std::string &onDelete="RESTRICT") |
| Set foreign key reference (fluent interface). | |
| MbEntitySchemaField & | removeForeignKey () |
| Remove foreign key constraint (fluent interface). | |
| nlohmann::json | constraints () const |
| Get all field constraints. | |
| nlohmann::json | constraint (const std::string &key) const |
| Get specific constraint by key. | |
| MbEntitySchemaField & | setConstraints (const nlohmann::json &opts) |
| Set field constraints (fluent interface). | |
| MbEntitySchemaField & | updateWith (const nlohmann::json &field_schema) |
| Update field with new JSON data. | |
| nlohmann::json | toJSON () const |
| Convert field to JSON representation. | |
| soci::db_type | toSociType () const |
| Convert field type to SOCI database type. | |
| std::optional< std::string > | validate () const |
| Validate field definition. | |
Static Public Member Functions | |
| static const std::vector< std::string > & | defaultBaseFields () |
| static const std::vector< std::string > & | defaultAuthFields () |
| static const std::vector< std::string > & | defaultEntityFieldTypes () |
| static soci::db_type | toSociType (const std::string &type) |
| static soci::db_type | toSociType (const std::string &type, MbIntPrecision precision) |
| static bool | isValidFieldType (const std::string &type) |
| Check if field type is valid. | |
| static bool | isValidFieldName (const std::string &name) |
| static std::string | genFieldId (const std::string &id) |
| Generate unique field ID from name. | |
| static const nlohmann::json & | defaultConstraints () |
| Get default constraints JSON. | |
| mb::MbEntitySchemaField::MbEntitySchemaField | ( | std::string | field_name, |
| std::string | field_type ) |
|
explicit |
Construct field from JSON schema object.
| field_schema | JSON object with field definition |
|
default |
|
nodiscard |
Get specific constraint by key.
| key | Constraint key (e.g., "min", "max", "validator") |
|
nodiscard |
Get all field constraints.
|
static |
|
static |
|
static |
Get default constraints JSON.
|
static |
|
nodiscard |
Get foreign key reference column name.
|
nodiscard |
Get foreign key delete policy.
|
nodiscard |
Get foreign key update policy.
|
nodiscard |
Get foreign key reference table name.
|
static |
Generate unique field ID from name.
| id | Field name or identifier |
|
nodiscard |
Get field unique identifier.
|
nodiscard |
|
nodiscard |
Check if field is a foreign key.
|
nodiscard |
Check if field is primary key.
|
nodiscard |
Check if field is system field.
|
nodiscard |
Check if field has unique constraint.
|
static |
|
static |
Check if field type is valid.
| type | Type string to validate |
|
nodiscard |
Get field name.
| bool mb::MbEntitySchemaField::operator== | ( | const MbEntitySchemaField & | other | ) | const |
| MbEntitySchemaField & mb::MbEntitySchemaField::removeForeignKey | ( | ) |
Remove foreign key constraint (fluent interface).
|
nodiscard |
Check if field is required.
| MbEntitySchemaField & mb::MbEntitySchemaField::setConstraints | ( | const nlohmann::json & | opts | ) |
Set field constraints (fluent interface).
| opts | JSON object with constraint values |
| MbEntitySchemaField & mb::MbEntitySchemaField::setForeignKey | ( | const std::string & | table, |
| const std::string & | column = "id", | ||
| const std::string & | onUpdate = "RESTRICT", | ||
| const std::string & | onDelete = "RESTRICT" ) |
Set foreign key reference (fluent interface).
| table | Reference table name |
| column | Reference column name (defaults to "id") |
| onUpdate | Update policy (defaults to "RESTRICT") |
| onDelete | Delete policy (defaults to "RESTRICT") |
| MbEntitySchemaField & mb::MbEntitySchemaField::setIntPrecision | ( | MbIntPrecision | precision | ) |
| MbEntitySchemaField & mb::MbEntitySchemaField::setIsPrimaryKey | ( | bool | pk | ) |
Set primary key flag (fluent interface).
| pk | Primary key flag |
| MbEntitySchemaField & mb::MbEntitySchemaField::setIsSystem | ( | bool | system | ) |
Set system field flag (fluent interface).
| system | System field flag |
| MbEntitySchemaField & mb::MbEntitySchemaField::setIsUnique | ( | bool | unique | ) |
Set unique constraint (fluent interface).
| unique | Unique flag |
| MbEntitySchemaField & mb::MbEntitySchemaField::setName | ( | const std::string & | name | ) |
Set field name (fluent interface).
| name | New field name |
| MbEntitySchemaField & mb::MbEntitySchemaField::setPrecision | ( | const std::string & | precision | ) |
Set precision from string token (i32, u64, …).
| MbEntitySchemaField & mb::MbEntitySchemaField::setRequired | ( | bool | required | ) |
Set required flag (fluent interface).
| required | Required flag |
| MbEntitySchemaField & mb::MbEntitySchemaField::setType | ( | const std::string & | type | ) |
Set field type (fluent).
|
nodiscard |
Convert field to JSON representation.
|
nodiscard |
Convert field type to SOCI database type.
|
staticnodiscard |
Map a type string to SOCI db_type (non-int types).
|
staticnodiscard |
Map int type + precision to SOCI db_type.
|
nodiscard |
Get field type.
| MbEntitySchemaField & mb::MbEntitySchemaField::updateWith | ( | const nlohmann::json & | field_schema | ) |
Update field with new JSON data.
| field_schema | JSON object with field updates |
|
nodiscard |
Validate field definition.