TDbRelation


This template class describes Active Record relations.

You can find more information in comments below.

template
class TDbRelation :public virtual IDbRelation, public CReleasable
public:
    TDbRelation( // Constructor representing One-to-One or One-to-Many relation 
        CDbBaseActiveRecord *parent,
        const String &name,
        const String &model_attribute,
        const String &parent_attribute,
        const bool many = false,
        const DbOrderByArray &orders = { });

    TDbRelation( // Constructor representing Many-to-Many relation 
        CDbBaseActiveRecord *parent,
        const String &name,
        const String &model_attribute,
        const String &parent_attribute,
        const Link &link,
        const DbOrderByArray &orders = { });

    ReleasablePtr<Model> operator->(); // Return first model or nullptr if no models in list. Load models first if they were not loaded yet (lazy loading) 
    ReleasablePtr<Model> operator[](const size_t index); // Return model by index or nullptr if index out of bounds. Load models first if they were not loaded yet (lazy loading) 
    const ReleasablePtr<Model> operator[](const size_t index) const; // Return model by index or nullptr if index out of bounds. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::iterator begin(); // Return iterator pointing to the beginning. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::iterator end(); // Return iterator pointing to the end. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::reverse_iterator rbegin(); // Return reverse iterator pointing to the beginning. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::reverse_iterator rend(); // Return reverse iterator pointing to the end. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::size_type size(); // Return count of models. Load models first if they were not loaded yet (lazy loading) 
    bool empty(); // Return whether there are any models in list. Load models first if they were not loaded yet (lazy loading) 
    void push_back(ReleasablePtr<Model> model); // Add new model to the list. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::iterator erase(typename std::vector<ReleasablePtr<Model>>::iterator pos); // Remove model at the specified position from the list and calls model's Delete() method. Load models first if they were not loaded yet (lazy loading) 
    typename std::vector<ReleasablePtr<Model>>::iterator erase(typename std::vector<ReleasablePtr<Model>>::iterator start, typename std::vector<ReleasablePtr<Model>>::iterator end); // Remove models range from the list and calls models' Delete() method. Load models first if they were not loaded yet (lazy loading) 
    void clear(const bool load); // Clear models and call theirs Delete() method. If "load" is true, models first loaded (if they are not loaded yet). If "load" is false, models won't be loaded and relation will be marked as already loaded so other operations will not load models (unless clear(true) is called) 
};
Namespace: nitisa
Include: Nitisa/Db/DbRelation.h