Support for embedded documents.

Models can formally define embedded documents, with are handled just
like the other fields. Small code refactors to db.py according to the
DRY principle.