aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-02 11:04:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-02 11:07:28 +0200
commited17172ea74a8beaaaf5f2494bd1fecc81ff6144 (patch)
tree475930953f47199fc2a8a7286b0dfe8148c3b690 /doc
parent1df3835ada62bd3c6d091469d4596589735abd18 (diff)
Add result_iterator::id() function that returns id without loading object
Diffstat (limited to 'doc')
-rw-r--r--doc/manual.xhtml22
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/manual.xhtml b/doc/manual.xhtml
index 690c17f..d262319 100644
--- a/doc/manual.xhtml
+++ b/doc/manual.xhtml
@@ -3837,6 +3837,9 @@ namespace odb
void
load (T&amp; x);
+
+ typename object_traits&lt;T>::id_type
+ id ();
};
}
</pre>
@@ -3905,6 +3908,25 @@ namespace odb
}
</pre>
+ <p>The <code>id()</code> function return the object id of the current
+ object. While we can achieve the same by loading the object and getting
+ its id, this function is more efficient since it doesn't actually
+ create the object. This can be useful when all we need is the object's
+ identifier. For example:</p>
+
+ <pre class="c++">
+ std::set&lt;unsigned long> set = ...; // Persons of interest.
+
+ result r (db.query&lt;person> (query::first == "John"));
+
+ for (result::iterator i (r.begin ()); i != r.end (); ++i)
+ {
+ if (set.find (i.id ()) != set.end ()) // No object loaded.
+ {
+ cout &lt;&lt; i->first () &lt;&lt; endl; // Object loaded.
+ }
+ }
+ </pre>
<!-- CHAPTER -->