aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-30 15:21:52 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-30 15:21:52 +0200
commit96f2e209e4bfcf463afe0b933735cf4f444d5609 (patch)
tree0d1bb8376af433f929d07e5edcd51d74460b05ef
parentdc776f696463db45d79d83520c146309441f175c (diff)
Add example of nested container to NEWS file
-rw-r--r--NEWS31
1 files changed, 30 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0d001db..0f5fac2 100644
--- a/NEWS
+++ b/NEWS
@@ -33,7 +33,36 @@ Version 2.5.0
* The 'inverse' pragma now supports nested data members.
* Helper header (<odb/nested-container.hxx>) for nested container emulation.
- It is still fairly experimental and only supports vector<vector<T>>.
+ It is still fairly experimental and only supports vector<vector<T>>. For
+ example:
+
+ #include <odb/nested-container.hxx>
+
+ #pragma db object
+ class package
+ {
+ using licenses_type = std::vector<std::string>
+ using license_alternatives_type = std::vector<licenses_type>
+
+ license_alternatives_type license_alternatives;
+
+ // Database mapping.
+ //
+ using _license_key = odb::nested_key<licenses_type>;
+ using _licenses_type = std::map<_license_key, std::string>;
+
+ #pragma db value(_license_key)
+ #pragma db member(_license_key::outer) column("alternative_index")
+ #pragma db member(_license_key::inner) column("index")
+
+ #pragma db member(license_alternatives) id_column("") value_column("")
+ #pragma db member(licenses) \
+ virtual(_licenses_type) \
+ after(license_alternatives) \
+ get(odb::nested_get (this.license_alternatives)) \
+ set(odb::nested_set (this.license_alternatives, std::move (?))) \
+ id_column("") key_column("") value_column("license")
+ };
* Database classes are now move-constructible. This means they can be
returned by value from a function in C++11.