HDK
|
#include <UT_ORMModelMeta.h>
Classes | |
struct | Related |
Public Member Functions | |
UT_ORMModelMeta (const UT_StringHolder &name, UT_SqlOrm *orm=nullptr) | |
UT_ORMModelMeta () | |
virtual | ~UT_ORMModelMeta ()=default |
UT_NON_COPYABLE (UT_ORMModelMeta) | |
void | setTableName (const UT_StringHolder &name) |
void | setModelName (const UT_StringHolder &name) |
void | setVerboseName (const UT_StringHolder &name) |
void | setPluralVerboseName (const UT_StringHolder &name) |
void | build (UT_SqlOrm &orm) |
Call to build out all of your meta information. More... | |
void | connectLinks () |
Called after all models concrete information has been connected. More... | |
virtual void | collectMigrations (UT_ORMMigrationBuilder &builder) const =0 |
virtual void | preConnectLinks () |
Called right before connecting the links on each model. More... | |
void | postMigrate () |
template<typename Cls , typename FieldT > | |
void | addAutoField (const UT_StringHolder &name, FieldT Cls::*field, unsigned props=UT_ORMColumn::Empty) |
template<typename Cls , typename FieldT > | |
void | addField (const UT_StringHolder &name, FieldT Cls::*field, unsigned props=UT_ORMColumn::Empty) |
template<typename Cls , typename ForeignModel > | |
void | addField (const UT_StringHolder &name, UT_ORMForeignKeyField< ForeignModel > Cls::*field, unsigned props=UT_ORMColumn::Empty, UT_ORMColumn::OnDelete ondelete_type=UT_ORMColumn::OnDelete::Cascade, const UT_StringHolder &related_name=UT_StringHolder::theEmptyString, const UT_ORMModelMeta &foreign_meta=ForeignModel::metaInfo()) |
template<typename Owner , typename OtherModel > | |
void | addField (const UT_StringHolder &name, UT_ORMManyToManyField< Owner, OtherModel > Owner::*field, const UT_StringHolder &related_name=UT_StringHolder::theEmptyString) |
const UT_StringHolder & | tableName () const |
const UT_StringHolder & | modelName () const |
const UT_StringHolder & | verboseName () const |
const UT_StringHolder & | pluralVerboseName () const |
const UT_ORMFieldColumn * | primaryKey () const |
const UT_Array < UT_ORMFieldColumn > & | columns () const |
const UT_Array< const UT_ORMFieldColumn * > & | foreignKeys () const |
const UT_Array< const UT_ORMFieldColumn * > & | uniqueColumns () const |
template<typename T > | |
bool | save (T &obj, UT_ErrorCode &ec, bool force_insert=false, bool force_update=false) const |
template<typename T > | |
void | remove (T &obj, UT_ErrorCode &ec) const |
template<typename T > | |
void | remove (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
template<typename T , typename PK > | |
UT_Optional< T > | fetch (const PK &pk, UT_ErrorCode &ec) const |
template<typename T > | |
UT_Array< T > | fetch (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
template<typename T > | |
UT_Array< T > | fetchAll (UT_ErrorCode &ec) const |
template<typename T > | |
UT_Optional< T > | filter (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
template<typename T > | |
std::pair< T, bool > | getOrCreate (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
template<typename T > | |
UT_Optional< T > | create (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
template<typename T , typename ArrayT > | |
UT_Array< T > | bulkFetch (const ArrayT &pks, UT_ErrorCode &ec, const UT_StringRef &col_name=UT_StringHolder::theEmptyString) const |
template<typename T > | |
void | bulkSave (const UT_Array< T > &items, UT_ErrorCode &ec) const |
template<typename T , typename... Args> | |
T | fromDB (Args &&...args) const |
template<typename T > | |
bool | exists (const std::initializer_list< UT::orm::FilterArg > &args, UT_ErrorCode &ec) const |
UT_SqlOrm * | orm () const |
UT_SqlStatement | cursor () const |
UT_SqlDatabase & | db () |
UT_SqlDatabase & | db () const |
template<typename T > | |
bool | loadObject (T &obj, UT_SqlStatement &stmt, UT_ErrorCode &ec) const |
template<typename T > | |
UT_Array< T > | loadAllObjects (UT_SqlStatement &stmt, UT_ErrorCode &ec) |
void | resetInternals () |
bool | hasField (const UT_StringView &name) const |
const UT_ORMFieldColumn * | findField (const UT_StringView &name) const |
const UT_ORMFieldColumn * | findForeignRelatedField (const UT_StringView &name) const |
bool | registerRelated (const UT_SharedPtr< UT_ORMModelMeta > &related, const UT_StringHolder &related_name, const UT_StringHolder &fk_field_name=UT_StringHolder::theEmptyString) |
UT_SharedPtr< UT_ORMModelMeta > | findRelated (const UT_StringView &name, UT_StringHolder &fk_field_name) const |
void | lookupTableColumns (const UT_StringRef &model_name, const UT_ORMFieldColumn *&fk_model, const UT_ORMFieldColumn *&fk_other_model) const |
bool | isThroughTable () const |
UT_ORMQuerySet | querySet () const |
Protected Member Functions | |
virtual void | doBuild ()=0 |
virtual void | doPostBuild () |
virtual void | doPostMigrate () |
void | configureConcrete_ () |
Configure any cacheable information that is used often. More... | |
void | registerM2M_ (const UT_SharedPtr< UT_ORMModelMeta > &left, const UT_SharedPtr< UT_ORMModelMeta > &right, const UT_StringHolder &field_name, const UT_StringHolder &related_name) |
UT_SharedPtr< UT_ORMModelMeta > | lookupMetaFromORM_ (const UT_StringView &name) const |
template<typename T > | |
bool | doUpdate_ (T &obj, UT_ErrorCode &ec) const |
template<typename T > | |
bool | doInsert_ (T &obj, UT_ErrorCode &ec) const |
Static Protected Member Functions | |
static void | addDynamicColumn_ (UT_ORMModelMeta &meta, UT_ORMFieldColumn &&field) |
Protected Attributes | |
bool | myHasBuilt = false |
bool | myHasPostBuilt = false |
bool | myHasPostMigrate = false |
bool | myIsThroughTable = false |
UT_StringHolder | myTableName |
UT_StringHolder | myModelName |
UT_StringHolder | myVerboseName |
UT_StringHolder | myPluralVerboseName |
const UT_ORMFieldColumn * | myPrimaryKey = nullptr |
UT_Array< const UT_ORMFieldColumn * > | myForeignKeys |
UT_Array< const UT_ORMFieldColumn * > | myUniqueColumns |
UT_Array< UT_ORMFieldColumn > | myColumns |
UT_Array< Related > | myRelated |
UT_SqlOrm * | myORM = nullptr |
Definition at line 45 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 48 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 54 of file UT_ORMModelMeta.h.
|
virtualdefault |
|
inline |
Definition at line 94 of file UT_ORMModelMeta.h.
|
inlinestaticprotected |
Definition at line 388 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 104 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 114 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 130 of file UT_ORMModelMeta.h.
UT_Array< T > UT_ORMModelMeta::bulkFetch | ( | const ArrayT & | pks, |
UT_ErrorCode & | ec, | ||
const UT_StringRef & | col_name = UT_StringHolder::theEmptyString |
||
) | const |
Definition at line 778 of file UT_ORMModelMeta.h.
void UT_ORMModelMeta::bulkSave | ( | const UT_Array< T > & | items, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 846 of file UT_ORMModelMeta.h.
|
pure virtual |
Implemented in UT_ORMContentType::Meta.
|
inline |
Definition at line 150 of file UT_ORMModelMeta.h.
|
protected |
Configure any cacheable information that is used often.
void UT_ORMModelMeta::connectLinks | ( | ) |
Called after all models concrete information has been connected.
UT_Optional< T > UT_ORMModelMeta::create | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 715 of file UT_ORMModelMeta.h.
UT_SqlStatement UT_ORMModelMeta::cursor | ( | ) | const |
UT_SqlDatabase& UT_ORMModelMeta::db | ( | ) |
UT_SqlDatabase& UT_ORMModelMeta::db | ( | ) | const |
|
protectedpure virtual |
Implemented in UT_ORMContentType::Meta.
|
protected |
Definition at line 471 of file UT_ORMModelMeta.h.
|
inlineprotectedvirtual |
Definition at line 368 of file UT_ORMModelMeta.h.
|
protectedvirtual |
Reimplemented in UT_ORMContentType::Meta.
|
protected |
Definition at line 448 of file UT_ORMModelMeta.h.
bool UT_ORMModelMeta::exists | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 915 of file UT_ORMModelMeta.h.
UT_Optional< T > UT_ORMModelMeta::fetch | ( | const PK & | pk, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 653 of file UT_ORMModelMeta.h.
UT_Array< T > UT_ORMModelMeta::fetch | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 628 of file UT_ORMModelMeta.h.
UT_Array< T > UT_ORMModelMeta::fetchAll | ( | UT_ErrorCode & | ec | ) | const |
Definition at line 673 of file UT_ORMModelMeta.h.
UT_Optional< T > UT_ORMModelMeta::filter | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 696 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 289 of file UT_ORMModelMeta.h.
|
inline |
Find a foreign concrete field based on the column name. The column name passed in must be for a local field that is a foreign key
Definition at line 300 of file UT_ORMModelMeta.h.
UT_SharedPtr<UT_ORMModelMeta> UT_ORMModelMeta::findRelated | ( | const UT_StringView & | name, |
UT_StringHolder & | fk_field_name | ||
) | const |
|
inline |
Definition at line 151 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 201 of file UT_ORMModelMeta.h.
std::pair< T, bool > UT_ORMModelMeta::getOrCreate | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 738 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 279 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 337 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 247 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 218 of file UT_ORMModelMeta.h.
|
protected |
void UT_ORMModelMeta::lookupTableColumns | ( | const UT_StringRef & | model_name, |
const UT_ORMFieldColumn *& | fk_model, | ||
const UT_ORMFieldColumn *& | fk_other_model | ||
) | const |
On a lookup table split the two columns up based on the provided model. This is helpful for quickly determining which column on the lookup table belongs to the provided concrete model and the other model.
|
inline |
Definition at line 143 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 212 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 145 of file UT_ORMModelMeta.h.
void UT_ORMModelMeta::postMigrate | ( | ) |
|
inlinevirtual |
Called right before connecting the links on each model.
Definition at line 90 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 149 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 339 of file UT_ORMModelMeta.h.
|
protected |
bool UT_ORMModelMeta::registerRelated | ( | const UT_SharedPtr< UT_ORMModelMeta > & | related, |
const UT_StringHolder & | related_name, | ||
const UT_StringHolder & | fk_field_name = UT_StringHolder::theEmptyString |
||
) |
void UT_ORMModelMeta::remove | ( | T & | obj, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 588 of file UT_ORMModelMeta.h.
void UT_ORMModelMeta::remove | ( | const std::initializer_list< UT::orm::FilterArg > & | args, |
UT_ErrorCode & | ec | ||
) | const |
Definition at line 617 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 265 of file UT_ORMModelMeta.h.
bool UT_ORMModelMeta::save | ( | T & | obj, |
UT_ErrorCode & | ec, | ||
bool | force_insert = false , |
||
bool | force_update = false |
||
) | const |
Definition at line 413 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 62 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 76 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 58 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 72 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 142 of file UT_ORMModelMeta.h.
|
inline |
Definition at line 155 of file UT_ORMModelMeta.h.
UT_ORMModelMeta::UT_NON_COPYABLE | ( | UT_ORMModelMeta | ) |
|
inline |
Definition at line 144 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 406 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 404 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 395 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 396 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 397 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 398 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 400 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 408 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 402 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 403 of file UT_ORMModelMeta.h.
Definition at line 407 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 399 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 405 of file UT_ORMModelMeta.h.
|
protected |
Definition at line 401 of file UT_ORMModelMeta.h.