drogon
drogon copied to clipboard
ORM get specific columns
Using the ORM library is it possible to only retrieve specific columns? I have a table with several columns 2 of which contain a huge string that is only used in specific situations.
For now I have to use a prepared statement for this case:
auto clientPtr = drogon::app().getDbClient("psql");
auto f = clientPtr->execSqlAsyncFuture(
"SELECT columns... WHERE key = $1, key);
auto result = f.get(); // Block until we get the result or catch the exception;
std::vector<drogon_model::db::Table> data;
for (auto row : result) {
drogon_model::db::table td(row, -1);
data.push_back(td);
}
Is there a way I can use the ORM library and prevent postgres from retrieving the two columns.
Example:
auto training_data = td_mapper.onlyColumns(columnlist...).findByPrimaryKey(trainingdataid);
Hopefully this question makes sense...