sqlite_orm
sqlite_orm copied to clipboard
iterate-like interface but for select with columns
Hi,
from the join example
auto rows = storage2.select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate),
left_join<Visit>(on(c(&Doctor::id) == &Visit::doctorId)));
for(auto &row : rows) {
cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl;
}
cout << endl;
rows is a std::vector<std::tuple<Columns...>>. it would be nice if the same query would be possible with iterate to get a view over std::tuple<Columns...> instead.
Hi. It is a very nice feature. I have been thinking about it several days ago. I think that API will look like that:
auto statement = storage.prepare(select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate),
left_join<Visit>(on(c(&Doctor::id) == &Visit::doctorId))));
for(auto &row: storage.iterate(statement)) { // decltype(row) is the std::tuple<...>
//..
}
and one can use any type of statement. What do you think?