Heart 1.3.848.aa44c26
Heart is base back end library for your c++ Qt projects.
|
The DeleteObject class is request for update object with dbId;. More...
#include <deleteobject.h>
Public Member Functions | |
DeleteObject () | |
DeleteObject (const DbAddress &address, const QString &primaryKey) | |
DeleteObject This is main constructor for request, you can remove any db object if you know them value of the primary key. | |
DeleteObject (const Package &pkg) | |
DBObject * | createDBObject () const override |
createDBObject This method should be create a object with the some type as the object called this method. Example of override: | |
DBVariantMap | variantMap () const override |
variantMap This method should be create a DBVariantMap implementation of this database object. | |
const AccessToken & | getSignToken () const override |
getSignToken This method should be return actually token of the user. | |
void | setSignToken (const AccessToken &token) override |
setSignToken This method sets a new token for object. | |
bool | fromSqlRecord (const QSqlRecord &q) override |
fromSqlRecord This method should be initialize this object from the executed sqlRecord. The Default implementation get general dbObject information ( id and table name ). Override This method for initialize this object from sql query. | |
bool | isCached () const override |
isCached This method sholud be return status of object. If this method return true then this object can be saved into cache of database. Override this method and set this value to false for composite objects (objects for which a select query can return several objects or an object that does not have a direct representation in the database but contains common characteristics of several objects). | |
QString | table () const override |
table This method should be return name of the database table that should be contains objects with this type. | |
const DbAddress & | address () const |
address This method return address of the object that will be deleted. | |
void | setAddress (const DbAddress &newAddress) |
setAddress This method sets new address for object that will be deleted from database. | |
void | setPrimaryKey (const QString &newPrimaryKey) |
setPrimaryKey This meethod sets new value of the primary key. | |
Public Member Functions inherited from QH::PKG::DBObject | |
DBObject () | |
~DBObject () override | |
bool | isValid () const override |
isValid This method check current object to valid. | |
bool | isHaveAPrimaryKey () const |
isHaveAPrimaryKey This method return true if this object has a primary key. If you want to cache this database object then primary key must be not null. | |
virtual void | clear () |
clear This method clear all data of database object. Override This method for remove or reset your own members of class. | |
virtual PrepareResult | prepareSelectQuery (QSqlQuery &q) const |
prepareSelectQuery This method should be prepare a query for selected data. Override this method for get item from database. The default implementation generate default select: | |
virtual PrepareResult | prepareInsertQuery (QSqlQuery &q, bool replace) const |
prepareInsertQuery This method should be prepare a query for insert object into database. You need to create a own insert sql query for this object into database. Override this method for insert item into database. By Default This method prepare a insert query using the data that returned from the variantMap method. | |
virtual PrepareResult | prepareUpdateQuery (QSqlQuery &q) const |
prepareUpdateQuery this method should be prepare a insert data query. | |
virtual PrepareResult | prepareRemoveQuery (QSqlQuery &q) const |
prepareRemoveQuery This method should be prepare a query for remove this object from a database. Override this method for remove this item from database. The default implementation remove item from id or primaryKey for more information see DBObject::condition method. | |
virtual bool | isBundle () const |
isBundle This method definef determines whether the object will be abstract (composite objects) or single object If this function return true then SqlDBWriter create only one object after invoked selectquery. And if the selectquery function return a list of more 1 elements then a method fromSqlRecord must be invoked for each all elements of list. | |
DbAddress | dbAddress () const |
dbAddress This method return address of the database object. IF the object is not valid then this method return an invalid database address. | |
QString | toString () const override |
Public Member Functions inherited from QH::PKG::AbstractData | |
~AbstractData () override | |
virtual unsigned short | cmd () const =0 |
cmd - This is command of this object, (for generate cmd use macross QH_PACKAGE) | |
virtual QString | cmdString () const =0 |
cmdString - This is command string of this object, (for generate cmd use macross QH_PACKAGE) | |
virtual bool | toPackage (Package &package, const DistVersion &reqVersion, unsigned int triggerHash=0) const |
toPackage This method convert this class object to the package. For more info see Package class. | |
QString | toString () const override |
toString - Return a string implementation for this object. | |
template<class C , class... Args> | |
C * | create (Args &&... args) const |
create - This is factory method for create a new object. | |
void | fromPakcage (const Package &pkg) |
fromPakcage - This method initialize the current object from a package class object. | |
Public Member Functions inherited from QH::StreamBase | |
StreamBase () | |
virtual | ~StreamBase () |
bool | fromBytes (const QByteArray &data) |
fromBytes This method provide initialization of object from byte array. | |
QByteArray | toBytes () const |
toBytes This method convert a current object to bytes array. | |
bool | fromBase64 (const QString &data) |
fromBase64 This method provide initialization of object from the base64 string. | |
bool | fromBase64 (const QByteArray &data) |
fromBase64 This method provide initialization of object from the base64 string. | |
QByteArray | toBase64 () const |
toBase64 This method convert a current object to the base64 string. | |
template<class T > | |
T & | copy (const StreamBase &right) |
copy This is base copy method for all StreamBase structures. Default implementation it is copy from byteArray. | |
template<class T > | |
bool | compare (const T &right) |
compare This method compare array signatures of this and right objects. | |
Public Member Functions inherited from QH::IToken | |
IToken ()=default | |
virtual | ~IToken ()=default |
Protected Member Functions | |
QString | primaryKey () const override |
primaryKey This method must be return the name of primary key of this object table. If you want to create data object without primary key just return empty string. | |
QVariant | primaryValue () const override |
primaryValue This method is wraper of DBAddress::id. If This object do not contains a id value then return invalid value. | |
QDataStream & | fromStream (QDataStream &stream) override |
fromStream This method should be read all bytes from the stream object and full the current object. | |
QDataStream & | toStream (QDataStream &stream) const override |
fromStream This method should be write all members of the current object to the stream object. | |
Protected Member Functions inherited from QH::PKG::DBObject | |
virtual std::pair< QString, QMap< QString, QVariant > > | condition () const |
condition This method must to return a condition of the WHERE block of the sql query. This method using on default implementation of DBObject::prepareSelectQuery and DBObject::prepareRemoveQuery methods. The default implementation generate when block by map for more information see the variantMap nethod. Override this method for customize your select or delete query. | |
bool | isInsertPrimaryKey () const |
isInsertPrimaryKey This method check primaryKeys type. If the primary key have a type MemberType::Insert then return true. | |
Protected Member Functions inherited from QH::PKG::AbstractData | |
AbstractData () | |
AbstractData - Base constructor of this object. | |
Protected Member Functions inherited from QH::StreamBase | |
virtual int | parsingVersion () const |
parsingVersion this method return parsing version of Qt. By Default is 0 (last available parsing). see https://doc.qt.io/qt-6/qdatastream.html#Version-enum | |
virtual unsigned int | typeId () const |
typeId This method return id of type. | |
Additional Inherited Members | |
Static Public Member Functions inherited from QH::PKG::AbstractData | |
static unsigned int | command () |
command This static method that return glaball code of this object. | |
static QString | commandText () |
commandText This method return text of package command | |
The DeleteObject class is request for update object with dbId;.
Example of use
Definition at line 26 of file deleteobject.h.
QH::PKG::DeleteObject::DeleteObject | ( | ) |
Definition at line 11 of file deleteobject.cpp.
QH::PKG::DeleteObject::DeleteObject | ( | const DbAddress & | address, |
const QString & | primaryKey | ||
) |
DeleteObject This is main constructor for request, you can remove any db object if you know them value of the primary key.
address | This is defautl addres of the ovject {table, id}. Where id is value of the primart key. |
primaryKey | This is primary key name - filed of the table. By default using id |
Definition at line 15 of file deleteobject.cpp.
QH::PKG::DeleteObject::DeleteObject | ( | const Package & | pkg | ) |
const DbAddress & QH::PKG::DeleteObject::address | ( | ) | const |
address This method return address of the object that will be deleted.
Definition at line 74 of file deleteobject.cpp.
|
overridevirtual |
createDBObject This method should be create a object with the some type as the object called this method. Example of override:
Implements QH::PKG::DBObject.
Definition at line 24 of file deleteobject.cpp.
|
overridevirtual |
fromSqlRecord This method should be initialize this object from the executed sqlRecord. The Default implementation get general dbObject information ( id and table name ). Override This method for initialize this object from sql query.
q | This is query object. |
Exampel of override fromSqlRecord method:
Implements QH::PKG::DBObject.
Definition at line 40 of file deleteobject.cpp.
|
overrideprotectedvirtual |
fromStream This method should be read all bytes from the stream object and full the current object.
stream | This is Qt stream object. |
Examle of base simple implementation:
Reimplemented from QH::PKG::DBObject.
Definition at line 45 of file deleteobject.cpp.
|
overridevirtual |
getSignToken This method should be return actually token of the user.
Implements QH::IToken.
Definition at line 32 of file deleteobject.cpp.
|
overridevirtual |
isCached This method sholud be return status of object. If this method return true then this object can be saved into cache of database. Override this method and set this value to false for composite objects (objects for which a select query can return several objects or an object that does not have a direct representation in the database but contains common characteristics of several objects).
Reimplemented from QH::PKG::DBObject.
Definition at line 66 of file deleteobject.cpp.
|
overrideprotectedvirtual |
primaryKey This method must be return the name of primary key of this object table. If you want to create data object without primary key just return empty string.
Reimplemented from QH::PKG::DBObject.
Definition at line 82 of file deleteobject.cpp.
|
overrideprotectedvirtual |
primaryValue This method is wraper of DBAddress::id. If This object do not contains a id value then return invalid value.
Reimplemented from QH::PKG::DBObject.
Definition at line 86 of file deleteobject.cpp.
void QH::PKG::DeleteObject::setAddress | ( | const DbAddress & | newAddress | ) |
setAddress This method sets new address for object that will be deleted from database.
newAddress | This is new value of the database adderess. |
Definition at line 78 of file deleteobject.cpp.
void QH::PKG::DeleteObject::setPrimaryKey | ( | const QString & | newPrimaryKey | ) |
setPrimaryKey This meethod sets new value of the primary key.
newPrimaryKey | This is new value of the primary key |
Definition at line 62 of file deleteobject.cpp.
|
overridevirtual |
setSignToken This method sets a new token for object.
token | This is new token value. |
Implements QH::IToken.
Definition at line 36 of file deleteobject.cpp.
|
overridevirtual |
table This method should be return name of the database table that should be contains objects with this type.
Implements QH::PKG::DBObject.
Definition at line 70 of file deleteobject.cpp.
|
overrideprotectedvirtual |
fromStream This method should be write all members of the current object to the stream object.
stream | This is Qt stream object. |
Examle of base simple implementation:
Reimplemented from QH::PKG::DBObject.
Definition at line 54 of file deleteobject.cpp.
|
overridevirtual |
variantMap This method should be create a DBVariantMap implementation of this database object.
IF you have the database field with autoincrement you need to remove MemberType::Insert attribute from the your key. For more information see the MemberType::PrimaryKeyAutoIncrement attribute.
Example of return value:
Example of override:
Reimplemented from QH::PKG::DBObject.
Definition at line 28 of file deleteobject.cpp.