EasyQtSql
Easy SQL data access helper for QtSql
EasyQtSql::Util Class Reference

Utility functions. More...

#include <EasyQtSql.h>

Static Public Member Functions

template<typename Func >
static int each (QueryResult &res, Func &&f)
 Applies function (lambda) f to each row in res. More...
 
template<typename Func >
static int range (QueryResult &res, int start, int count, Func &&f)
 Applies function (lambda) f to count rows starting from start index. More...
 
template<typename Func >
static int top (QueryResult &res, int topCount, Func &&f)
 Applies function (lambda) f to topCount rows from res. More...
 
template<typename Func >
static int first (QueryResult &res, Func &&f)
 Applies function (lambda) f to first result row. More...
 

Detailed Description

Utility functions.

t.first("SELECT 1", [](const QueryResult &row){
qDebug() << row.scalar<bool>();
});
t.each("SELECT * FROM table1", [](const QueryResult &row){
qDebug() << row.toMap();
});
PreparedQuery query = t.prepare("SELECT a, b, c, d FROM table1 WHERE a = ? AND b = ?");
Util::each(query.exec(1, 2), [](const QueryResult &row){
qDebug() << row.toMap();
});

Member Function Documentation

◆ each()

template<typename Func >
static int EasyQtSql::Util::each ( QueryResult res,
Func &&  f 
)
inlinestatic

Applies function (lambda) f to each row in res.

Parameters
resQueryResult
fFunction

◆ first()

template<typename Func >
static int EasyQtSql::Util::first ( QueryResult res,
Func &&  f 
)
inlinestatic

Applies function (lambda) f to first result row.

Parameters
resQueryResult
fFunction

◆ range()

template<typename Func >
static int EasyQtSql::Util::range ( QueryResult res,
int  start,
int  count,
Func &&  f 
)
inlinestatic

Applies function (lambda) f to count rows starting from start index.

Parameters
resQueryResult
startIndex of start row
countRows count
fFunction

◆ top()

template<typename Func >
static int EasyQtSql::Util::top ( QueryResult res,
int  topCount,
Func &&  f 
)
inlinestatic

Applies function (lambda) f to topCount rows from res.

Parameters
resQueryResult
topCountCount of rows
countRows count
fFunction

The documentation for this class was generated from the following file: