HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ORMModelMeta Class Referenceabstract

#include <UT_SQLORM.h>

Public Member Functions

 UT_ORMModelMeta (const UT_StringHolder &name, UT_SqlOrm *orm=nullptr)
 
virtual ~UT_ORMModelMeta ()=default
 
 UT_NON_COPYABLE (UT_ORMModelMeta)
 
void migrate (UT_SqlOrm &orm, UT_ORMMigrationBuilder &builder) const
 Must always be called PRIOR to running the application. More...
 
void build ()
 Call to build out all of your meta information. More...
 
virtual void doMigrate (UT_ORMMigrationBuilder &builder) const =0
 
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::DoNothing)
 
const UT_StringHoldertableName () const
 
const UT_ORMFieldColumnprimaryKey () const
 
const UT_Array
< UT_ORMFieldColumn > & 
columns () 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 >
bool update (T &obj, UT_ErrorCode &ec) const
 
template<typename T , typename PK >
UT_Optional< Tfetch (const PK &pk, UT_ErrorCode &ec) const
 
template<typename T >
UT_Array< TfetchAll (UT_ErrorCode &ec) const
 

Protected Member Functions

virtual void doBuild ()=0
 
template<typename T >
bool loadObject_ (T &obj, UT_SqlStatement &stmt, UT_ErrorCode &ec) const
 
void configureInternals_ ()
 Configure any cacheable information that is used often. More...
 

Protected Attributes

bool myHasBuilt = false
 
bool myIsUsingAutoIncPK = false
 
UT_StringHolder myName
 
UT_Array< UT_ORMFieldColumnmyColumns
 
UT_SqlOrmmyORM = nullptr
 

Detailed Description

Definition at line 123 of file UT_SQLORM.h.

Constructor & Destructor Documentation

UT_ORMModelMeta::UT_ORMModelMeta ( const UT_StringHolder name,
UT_SqlOrm orm = nullptr 
)
inline

Definition at line 126 of file UT_SQLORM.h.

virtual UT_ORMModelMeta::~UT_ORMModelMeta ( )
virtualdefault

Member Function Documentation

template<typename Cls , typename FieldT >
void UT_ORMModelMeta::addAutoField ( const UT_StringHolder name,
FieldT Cls::*  field,
unsigned  props = UT_ORMColumn::Empty 
)
inline

Definition at line 154 of file UT_SQLORM.h.

template<typename Cls , typename FieldT >
void UT_ORMModelMeta::addField ( const UT_StringHolder name,
FieldT Cls::*  field,
unsigned  props = UT_ORMColumn::Empty 
)
inline

Definition at line 164 of file UT_SQLORM.h.

template<typename Cls , typename ForeignModel >
void UT_ORMModelMeta::addField ( const UT_StringHolder name,
UT_ORMForeignKeyField< ForeignModel > Cls::*  field,
unsigned  props = UT_ORMColumn::Empty,
UT_ORMColumn::OnDelete  ondelete_type = UT_ORMColumn::OnDelete::DoNothing 
)
inline

Definition at line 174 of file UT_SQLORM.h.

void UT_ORMModelMeta::build ( )
inline

Call to build out all of your meta information.

Definition at line 137 of file UT_SQLORM.h.

const UT_Array<UT_ORMFieldColumn>& UT_ORMModelMeta::columns ( ) const
inline

Definition at line 200 of file UT_SQLORM.h.

void UT_ORMModelMeta::configureInternals_ ( )
protected

Configure any cacheable information that is used often.

virtual void UT_ORMModelMeta::doBuild ( )
protectedpure virtual
virtual void UT_ORMModelMeta::doMigrate ( UT_ORMMigrationBuilder builder) const
pure virtual
template<typename T , typename PK >
UT_Optional< T > UT_ORMModelMeta::fetch ( const PK &  pk,
UT_ErrorCode ec 
) const

Definition at line 601 of file UT_SQLORM.h.

template<typename T >
UT_Array< T > UT_ORMModelMeta::fetchAll ( UT_ErrorCode ec) const

Definition at line 652 of file UT_SQLORM.h.

template<typename T >
bool UT_ORMModelMeta::loadObject_ ( T obj,
UT_SqlStatement stmt,
UT_ErrorCode ec 
) const
inlineprotected

Definition at line 221 of file UT_SQLORM.h.

void UT_ORMModelMeta::migrate ( UT_SqlOrm orm,
UT_ORMMigrationBuilder builder 
) const

Must always be called PRIOR to running the application.

const UT_ORMFieldColumn* UT_ORMModelMeta::primaryKey ( ) const
inline

Definition at line 188 of file UT_SQLORM.h.

template<typename T >
void UT_ORMModelMeta::remove ( T obj,
UT_ErrorCode ec 
) const

Definition at line 463 of file UT_SQLORM.h.

template<typename T >
bool UT_ORMModelMeta::save ( T obj,
UT_ErrorCode ec,
bool  force_insert = false,
bool  force_update = false 
) const

Definition at line 323 of file UT_SQLORM.h.

const UT_StringHolder& UT_ORMModelMeta::tableName ( ) const
inline

Definition at line 187 of file UT_SQLORM.h.

template<typename T >
bool UT_ORMModelMeta::update ( T obj,
UT_ErrorCode ec 
) const

Definition at line 510 of file UT_SQLORM.h.

UT_ORMModelMeta::UT_NON_COPYABLE ( UT_ORMModelMeta  )

Member Data Documentation

UT_Array<UT_ORMFieldColumn> UT_ORMModelMeta::myColumns
protected

Definition at line 251 of file UT_SQLORM.h.

bool UT_ORMModelMeta::myHasBuilt = false
protected

Definition at line 248 of file UT_SQLORM.h.

bool UT_ORMModelMeta::myIsUsingAutoIncPK = false
protected

Definition at line 249 of file UT_SQLORM.h.

UT_StringHolder UT_ORMModelMeta::myName
protected

Definition at line 250 of file UT_SQLORM.h.

UT_SqlOrm* UT_ORMModelMeta::myORM = nullptr
protected

Definition at line 252 of file UT_SQLORM.h.


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