QEloquent 1.1.0
Qt most flexible ORM.
Loading...
Searching...
No Matches
QEloquent::Relation< Model > Class Template Reference

User-facing class for managing model relationships. More...

#include <relation.h>

Inherits QEloquent::Entity, QEloquent::AbstractItemProxy< T >, QEloquent::AbstractListProxy< T >, and Serializable.

Public Member Functions

 Relation ()
 Default constructor (uninitialized)
 
 Relation (const QString &name, ParentModel *parent, const std::function< RelationData *()> &creationCallback)
 Internal constructor used by Model factory methods.
 
 Relation (const std::source_location &location, const ParentModel *parent, const std::function< RelationData *()> &creationCallback)
 Constructor.
 
 Relation (const Relation &other)=default
 Copy constructor.
 
 Relation (Relation &&other)=default
 Move constructor.
 
Relation< Model > & operator= (const Relation &other)=default
 Copy assignment operator.
 
Relation< Model > & operator= (Relation &&other)=default
 Move assignment operator.
 
bool hasPivotData (int index, const QString &name) const
 Check if associated metadata exists at a given index.
 
QVariant pivotData (int index, const QString &name) const
 Retrieve associated metadata.
 
void setPivotData (int index, const QString &name, const QVariant &value)
 Set associated metadata.
 
bool exists () override
 Returns true if related models exist in the database (triggers load)
 
bool get () override
 Manually fetches related models from the database.
 
bool save () override
 Unsupported for relations directly.
 
bool insert () override
 Unsupported for relations directly.
 
bool update () override
 Unsupported for relations directly.
 
bool deleteData () override
 Unsupported for relations directly.
 
QList< RelatedModelrelated () const
 Explicitly returns the list of related models.
 

Detailed Description

template<typename Model>
class QEloquent::Relation< Model >

User-facing class for managing model relationships.

Relationships are accessed as methods on the model:

Relation<Stock> stock = product.stock();
if (stock) {
qDebug() << stock->quantity;
}
User-facing class for managing model relationships.
Definition relation.h:88
Template Parameters
ModelThe type of the related model.

The documentation for this class was generated from the following file: