|
Lightweight 0.20260921.0
|
SQL query result row iterator. More...
#include <SqlStatement.hpp>
Public Types | |
| using | QueryCustomizer = std::function< void(SqlSelectQueryBuilder &)> |
Public Member Functions | |
| SqlRowIterator (SqlConnection &conn) | |
| Constructs a row iterator over all rows of the record's table, using the given SQL connection. | |
| SqlRowIterator (SqlConnection &conn, QueryCustomizer queryCustomizer) | |
| iterator | begin () |
| Returns an iterator to the first row of the result set. | |
| iterator | end () noexcept |
| Returns a sentinel iterator representing the end of the result set. | |
SQL query result row iterator.
Can be used to iterate over rows of the database and fetch them into a record type.
| T | The record type to fetch the rows into. struct MyRecord
{
Field<int> field2;
Field<double> field3;
};
{
// row is of type MyRecord
// row.field1, row.field2, row.field3 are accessible
}
|
Pass a second argument to iterate over a subset of the table only. The callable receives the underlying SqlSelectQueryBuilder with the projection for T already applied, so the full WHERE / ORDER BY / LIMIT surface of the query builder is available:
Definition at line 1086 of file SqlStatement.hpp.
| using Lightweight::SqlRowIterator< T >::QueryCustomizer = std::function<void(SqlSelectQueryBuilder&)> |
Callable refining the SELECT query before it is executed.
It is invoked with the query builder that already carries the projection for T. Any value the callable returns is ignored, so the builder's chaining methods can be returned directly.
Definition at line 1093 of file SqlStatement.hpp.
|
inlineexplicit |
Constructs a row iterator over all rows of the record's table, using the given SQL connection.
Definition at line 1096 of file SqlStatement.hpp.
|
inline |
Constructs a row iterator over the subset of rows selected by queryCustomizer.
| conn | The SQL connection to run the query on. |
| queryCustomizer | Callable refining the SELECT query, e.g. by adding WHERE conditions. |
Definition at line 1105 of file SqlStatement.hpp.
|
inline |
Returns an iterator to the first row of the result set.
Definition at line 1185 of file SqlStatement.hpp.
|
inlinenoexcept |
Returns a sentinel iterator representing the end of the result set.
Definition at line 1196 of file SqlStatement.hpp.