A hands-on introduction to Wt::Dbo
==================================
Koen Deforche <koen@emweb.be> +
For Wt 4.0.5 (December 2018)
:doc: link:../reference/html/
:cpp: pass:[C++]
== Introduction
+Wt::Dbo+ is a {cpp} ORM (Object Relational Mapping) library.
The library is distributed as part of http://www.webtoolkit.eu/wt[Wt]
for building database-driven web applications, but may be equally well
used independently from it.
The library provides a class-based view on database tables which keeps
an object hierarchy of database objects automatically synchronized with
a database by inserting, updating and deleting database
records. {cpp} classes map to database tables, class fields to
table columns, and pointers and collections of pointers to database
relations. An object from a mapped class is called a *database object*
(dbo). Query results may be defined in terms of database objects,
primitives, or tuples of these.
A modern {cpp} approach is used to solve the mapping problem. Rather
than resorting to XML-based descriptions of how {cpp} classes and
fields should map onto tables and columns, or using obscure macros,
the mapping is defined entirely in {cpp} code.
In this tutorial, we will work our way through a blogging example,
similar to the one that is distributed with the library.
[TIP]
===============================
The complete source code for the examples used in this tutorial are
available as ready-to-run programs in the +examples/feature/dbo/+ folder
of
http://www.webtoolkit.eu/wt/download[Wt].
===============================
== Mapping a single class
We will start off with using +Wt::Dbo+ for mapping a single class +User+
to a corresponding table +user+.
[WARNING]
===============================
In this tutorial and the examples, we alias the namespace +Wt::Dbo+ to
+dbo+, and in our explanation we will refer to types and methods
available in that namespace directly.
===============================