diff options
author | louiz’ <louiz@louiz.org> | 2019-09-27 20:55:15 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2019-09-27 20:57:30 +0200 |
commit | 4b8d3430c7fff8b869ec895dbffac748db72a237 (patch) | |
tree | cc472dec9485f7cb4886900f313d5231229507c8 /src/database/select_query.hpp | |
parent | 05ba076a0ec451a5a67410731f5ea23ec1faaa74 (diff) | |
download | biboumi-4b8d3430c7fff8b869ec895dbffac748db72a237.tar.gz biboumi-4b8d3430c7fff8b869ec895dbffac748db72a237.tar.bz2 biboumi-4b8d3430c7fff8b869ec895dbffac748db72a237.tar.xz biboumi-4b8d3430c7fff8b869ec895dbffac748db72a237.zip |
Add an AsyncResult type to iterate over the Select resultsasync_sql
Diffstat (limited to 'src/database/select_query.hpp')
-rw-r--r-- | src/database/select_query.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/database/select_query.hpp b/src/database/select_query.hpp index e372f2e..1399417 100644 --- a/src/database/select_query.hpp +++ b/src/database/select_query.hpp @@ -8,6 +8,7 @@ #include <database/query.hpp> #include <logger/logger.hpp> #include <database/row.hpp> +#include <database/async_result.hpp> #include <utils/optional_bool.hpp> @@ -131,6 +132,15 @@ struct SelectQuery: public Query return rows; } + AsyncResult<T...> execute_async(DatabaseEngine& db) + { + auto statement = db.prepare(this->body); + if (!statement) + return {{}, {}}; + statement->bind(std::move(this->params)); + return {std::move(statement), this->table_name}; + } + const std::string table_name; }; |