The Model class is the base class for all ORM models.
More...
Inherits QEloquent::Entity, Serializable, and Deserializable.
|
|
| Model (const Model &) |
| | Copy constructor.
|
| |
|
| Model (Model &&) |
| | Move constructor.
|
| |
|
Model & | operator= (const Model &) |
| | Copy assignment operator.
|
| |
|
Model & | operator= (Model &&) |
| | Move assignment operator.
|
| |
|
virtual | ~Model () |
| | Virtual destructor.
|
| |
|
QVariant | primary () const |
| | Returns the value of the primary key.
|
| |
|
void | setPrimary (const QVariant &value) |
| | Sets the primary key value.
|
| |
|
QVariant | property (const QString &name) const |
| | Returns a property value by name.
|
| |
|
void | setProperty (const QString &name, const QVariant &value) |
| | Sets a property value by name.
|
| |
|
bool | exists () override final |
| | Returns true if the model exists in the database.
|
| |
|
bool | get () override final |
| | Refreshes the model data from the database.
|
| |
|
bool | insert () override final |
| | Inserts the model into the database.
|
| |
|
bool | update () override final |
| | Updates the model in the database.
|
| |
|
bool | deleteData () override final |
| | Deletes the model from the database.
|
| |
|
bool | load (const QString &relation) |
| | Eagerly loads a relationship.
|
| |
|
bool | load (const QStringList &relations) |
| | Eagerly loads multiple relationships.
|
| |
|
Query | lastQuery () const |
| | Returns the last query executed by this model.
|
| |
|
Error | lastError () const |
| | Returns the last error encountered by this model.
|
| |
|
MetaObject | metaObject () const |
| | Returns the metadata object for this model.
|
| |
|
Connection | connection () const |
| | Returns the database connection used by this model.
|
| |
|
| template<typename T > |
| Relation< T > | hasOne (const QString &foreignKey=QString(), const QString &localKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines a one-to-one relationship.
|
| |
| template<typename T > |
| Relation< T > | hasMany (const QString &foreignKey=QString(), const QString &localKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines a one-to-many relationship.
|
| |
| template<typename T , typename Through > |
| Relation< T > | hasManyThrough (const QString &foreignKey=QString(), const QString &localKey=QString(), const QString &throughForeignKey=QString(), const QString &throughLocalKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines a has-many-through relationship.
|
| |
| template<typename T > |
| Relation< T > | belongsTo (const QString &foreignKey=QString(), const QString &ownerKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines an inverse one-to-one or many-to-one relationship.
|
| |
| template<typename T > |
| Relation< T > | belongsToMany (const QString &table=QString(), const QString &foreignPivotKey=QString(), const QString &relatedPivotKey=QString(), const QString &parentKey=QString(), const QString &relatedKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines a many-to-many relationship.
|
| |
| template<typename T , typename Through > |
| Relation< T > | belongsToManyThrough (const QString &table=QString(), const QString &foreignPivotKey=QString(), const QString &relatedPivotKey=QString(), const QString &parentKey=QString(), const QString &relatedKey=QString(), const std::source_location &location=std::source_location::current()) const |
| | Defines a belongs-to-many-through relationship.
|
| |
The Model class is the base class for all ORM models.
It provides the core functionality for attribute management, persistence, and relationship definition. Models are typically defined using Q_GADGET and Q_PROPERTY macros to enable reflection and database mapping.
◆ hasOne()
template<typename T >
| Relation< T > QEloquent::Model::hasOne |
( |
const QString & |
foreignKey = QString(), |
|
|
const QString & |
localKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines a one-to-one relationship.
- Parameters
-
| foreignKey | The foreign key of the related model. |
| localKey | The local key of the parent model. |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
◆ hasMany()
template<typename T >
| Relation< T > QEloquent::Model::hasMany |
( |
const QString & |
foreignKey = QString(), |
|
|
const QString & |
localKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines a one-to-many relationship.
- Parameters
-
| foreignKey | The foreign key of the related model. |
| localKey | The local key of the parent model. |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
◆ hasManyThrough()
template<typename T , typename Through >
| Relation< T > QEloquent::Model::hasManyThrough |
( |
const QString & |
foreignKey = QString(), |
|
|
const QString & |
localKey = QString(), |
|
|
const QString & |
throughForeignKey = QString(), |
|
|
const QString & |
throughLocalKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines a has-many-through relationship.
- Parameters
-
| foreignKey | The foreign key of the intermediate model. |
| localKey | The local key of the parent model. |
| throughForeignKey | The foreignKey referenced on the through table |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
◆ belongsTo()
template<typename T >
| Relation< T > QEloquent::Model::belongsTo |
( |
const QString & |
foreignKey = QString(), |
|
|
const QString & |
ownerKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines an inverse one-to-one or many-to-one relationship.
- Parameters
-
| foreignKey | The foreign key of the current model. |
| ownerKey | The owner key of the related model. |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
◆ belongsToMany()
template<typename T >
| Relation< T > QEloquent::Model::belongsToMany |
( |
const QString & |
table = QString(), |
|
|
const QString & |
foreignPivotKey = QString(), |
|
|
const QString & |
relatedPivotKey = QString(), |
|
|
const QString & |
parentKey = QString(), |
|
|
const QString & |
relatedKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines a many-to-many relationship.
- Parameters
-
| table | The pivot table name. |
| foreignPivotKey | The foreign key of the current model in the pivot table. |
| relatedPivotKey | The foreign key of the related model in the pivot table. |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
◆ belongsToManyThrough()
template<typename T , typename Through >
| Relation< T > QEloquent::Model::belongsToManyThrough |
( |
const QString & |
table = QString(), |
|
|
const QString & |
foreignPivotKey = QString(), |
|
|
const QString & |
relatedPivotKey = QString(), |
|
|
const QString & |
parentKey = QString(), |
|
|
const QString & |
relatedKey = QString(), |
|
|
const std::source_location & |
location = std::source_location::current() |
|
) |
| const |
|
inlineprotected |
Defines a belongs-to-many-through relationship.
- Parameters
-
| table | The pivot table name. |
| foreignPivotKey | The foreign key of the intermediate model in the pivot table. |
| relatedPivotKey | The foreign key of the related model in the pivot table. |
| location | The source location, used to compute the function name to name relation. |
- Returns
- A Relation object.
The documentation for this class was generated from the following files: