Skip to content

Commit f6b5404

Browse files
authored
Add a new overload for execSqlCoro (#2314)
1 parent 46b5c90 commit f6b5404

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

orm_lib/inc/drogon/orm/DbClient.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,28 @@ class DROGON_EXPORT DbClient : public trantor::NonCopyable
214214
(binder << std::forward<Arguments>(args), 0)...};
215215
return internal::SqlAwaiter(std::move(binder));
216216
}
217+
218+
/**
219+
* @brief Execute a SQL query asynchronously using coroutine support.
220+
* This overload accepts a vector of arguments to bind to the query.
221+
* @tparam T The type of the elements in the vector.
222+
* @param sql The SQL query string to execute.
223+
* @param args A vector of arguments to bind to the query.
224+
* @return A SqlAwaiter object that can be co_awaited to retrieve the query
225+
* result.
226+
* @note This method is only available when coroutine support is enabled.
227+
*/
228+
template <typename T>
229+
internal::SqlAwaiter execSqlCoro(const std::string &sql,
230+
const std::vector<T> &args) noexcept
231+
{
232+
auto binder = *this << sql;
233+
for (const auto &arg : args)
234+
{
235+
binder << arg;
236+
}
237+
return internal::SqlAwaiter(std::move(binder));
238+
}
217239
#endif
218240

219241
/// Streaming-like method for sql execution. For more information, see the

0 commit comments

Comments
 (0)