Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (1,05 KB) Statistiken
| Zweig: | Revision:
b7446f4c Christian Ehringfeld
#include <QCoreApplication>
#include <QDir>
#include <QDebug>
9c269b1f Christian Ehringfeld
#include "article.h"
886bdb22 Christian Ehringfeld
#include "entitymanager.h"
9c269b1f Christian Ehringfeld
#include "entityinstancefactory.h"
0ec1cbfb Christian Ehringfeld

b7446f4c Christian Ehringfeld
using namespace CuteEntityManager;
int main(int argc, char *argv[]) {
9c269b1f Christian Ehringfeld
Q_UNUSED(argc) Q_UNUSED(argv)
EntityInstanceFactory::registerClass<Article>();
c5d0ed54 Christian Ehringfeld
QSharedPointer<CuteEntityManager::EntityManager> e =
1a9e6412 Christian Ehringfeld
QSharedPointer<CuteEntityManager::EntityManager>(new
CuteEntityManager::EntityManager("QSQLITE",
QDir::currentPath() + "/db.sqlite"));
9c269b1f Christian Ehringfeld
QStringList inits = QStringList() << "Article";
b7446f4c Christian Ehringfeld
e->startup("0.1", inits);
9c269b1f Christian Ehringfeld
QSharedPointer<Article> a = QSharedPointer<Article>(new Article(5.0,
"muesli"));
auto ep = a.objectCast<CuteEntityManager::Entity>();
qDebug() << e->create(ep, true, true); //INSERT on database
a->setPrice(6.0); //inflation
a->setName("muesli improved"); //1337 muesli upgrade
qDebug() << e->save(ep); //UPDATE on database
qDebug() << e->remove(ep); //REMOVE on database
b7446f4c Christian Ehringfeld
return 0;
}