drogonframework / drogonframework/drogon

ORM get specific columns

Open
#2,172 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

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 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...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.