Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORM get specific columns #2172

Open
Ayman250 opened this issue Sep 30, 2024 · 0 comments
Open

ORM get specific columns #2172

Ayman250 opened this issue Sep 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Ayman250
Copy link

Ayman250 commented Sep 30, 2024

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

@an-tao an-tao added the enhancement New feature or request label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants