pgLab/pglab/CrudModel.cpp
2018-01-08 20:45:52 +01:00

31 lines
730 B
C++

#include "CrudModel.h"
#include "OpenDatabase.h"
#include "PgDatabaseCatalog.h"
#include "PgAttributeContainer.h"
#include "PgConstraintContainer.h"
#include <string>
CrudModel::CrudModel()
: m_dbConn(*getGlobalAsioIoService())
{}
CrudModel::~CrudModel()
{
m_dbConn.closeConnection();
}
/*
* Strategy
* when ordered by primary key, offset and limit work very quickly so we can get away with not loading
* everything.
*/
void CrudModel::setData(std::shared_ptr<OpenDatabase> db, const PgClass &table)
{
m_database = db;
m_table = table;
m_primaryKey = db->catalogue()->constraints()->getPrimaryForRelation(table.oid);
//cat->attributes()->getColumnsForRelation()
m_dbConn.setupConnection(m_database.config());
}