aboutsummaryrefslogtreecommitdiff
path: root/view
diff options
context:
space:
mode:
authorMichael Shepanski <michael@codesynthesis.com>2014-11-06 16:33:35 +1100
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-10 16:48:13 +0200
commit51a01cfebf933d270bf7b7fadb0fb3ca3b7a4cd5 (patch)
tree40ca9efb48c65e88822bcb7538d64bf1299d7aaf /view
parentf7d0e9c620d7c3117074e2618f2bc75699d6f2f0 (diff)
Implement {query,execute}_{one,value}() shortcut functions
Useful in situations where the query is know to return at most one element (*_one) or exactly one element (*_value).
Diffstat (limited to 'view')
-rw-r--r--view/driver.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/view/driver.cxx b/view/driver.cxx
index 36274d6..cbe26ee 100644
--- a/view/driver.cxx
+++ b/view/driver.cxx
@@ -179,12 +179,14 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- result<employee_count> r (
- db->query<employee_count> (query<employee_count>::last == "Doe"));
-
- // Result of this aggregate query contains only one element.
+ // Result of an aggregate query contains only one element so let's
+ // use the query_value() shortcut.
//
- cout << r.begin ()->count << " employees with the Doe last name" << endl
+ employee_count ec (
+ db->query_value<employee_count> (
+ query<employee_count>::last == "Doe"));
+
+ cout << ec.count << " employees with the Doe last name" << endl
<< endl;
t.commit ();