Added support for database maintenance. Added core plugin.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/transaction.hxx>
|
||||
@@ -39,6 +40,9 @@ public:
|
||||
|
||||
void save(QSharedPointer<T> entity) {
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
db->persist(entity);
|
||||
tx.commit();
|
||||
@@ -46,11 +50,21 @@ public:
|
||||
|
||||
QSharedPointer<T> loadById(int id) {
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
QSharedPointer<T> entity = db->template load<T>(id);
|
||||
tx.commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
void setPluginId(const QString &pluginId) {
|
||||
m_pluginId = pluginId;
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_pluginId;
|
||||
};
|
||||
|
||||
#endif // SERVICE_H
|
||||
|
||||
Reference in New Issue
Block a user