diff options
author | Michael Shepanski <michael@codesynthesis.com> | 2014-11-06 16:33:35 +1100 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-11-10 16:48:13 +0200 |
commit | 51a01cfebf933d270bf7b7fadb0fb3ca3b7a4cd5 (patch) | |
tree | 40ca9efb48c65e88822bcb7538d64bf1299d7aaf /view | |
parent | f7d0e9c620d7c3117074e2618f2bc75699d6f2f0 (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.cxx | 12 |
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 (); |