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

Retrieve varidic values from a query #13

Open
gtnardy opened this issue Feb 22, 2022 · 1 comment
Open

Retrieve varidic values from a query #13

gtnardy opened this issue Feb 22, 2022 · 1 comment

Comments

@gtnardy
Copy link

gtnardy commented Feb 22, 2022

Hello there @znone!

Is there a way to retrieve variadic values from a query, like in a variant way or even using a map of std::any? My intention is to dynamically iterate through the fields of a query.

For example:

db.query("select 0, 'hello world'", 
    [](const std::unordered_map<std::string, std::any>& record)
    {
         for (const auto& field : record)
             // get the field of any value
    }
 );
@znone
Copy link
Owner

znone commented Mar 11, 2022

This function has been implemented. You can try it.

db.query("select 0, 'hello world'", 
    [](const std::any& v1, const std::any& v2)
    {
          int i = std::get<int>(v1);
          std::string s = std::get<std::string>(v2);
    }
 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants