OpenWGA 7.10 - OpenWGA Concepts and Features

Design and development » HDBModel framework » HDBModel in TMLScript

The "HDBModel" object

In TMLScript the HDBModel functionality is represented by a TMLScript global that is automatically created once an app has a model definition: The "HDBModel" object.

On this object you will find methods for all operations that HDBModel is capable of, including those that are used by built-in OpenWGA functionalities like default action "$store" or automatic relation option retrieval.

Basis of all HDBModel operations are the specific methods to create, update and delete:

While there are only few - expected - mandatory arguments to these operations there is also a plethora of optional parameters available, which you may want to use in special situations. Therefor all these possible arguments are collected in one central parameter object: HDBModelParams. It can be created - already prefilled with mandatory arguments per operation - via methods HDBModel.newCreateContentParams(), HDBModel.newUpdateContentParams() and HDBModel.newDeleteContentParams().

On this object you can first specify your desired params (although all that are not necessary to create the params object are optional), then pass it on to the method for the operation you want to do. An example creating a document while directly defining a content id for it:

var params = HDBModel.newCreateContentParams("issue", content()); // Gives content class to create and "reference content"

params.createContentID = request.getParameter("name");

var newContent  = HDBModel.createContent(params);

However for every operation method there are also argument variants that avoid the intermediate HDBModelParams object and take the most frequently used parameters directly. So if I do not want to directly specify a content id I could also do:

HDBModel.createContent("issue", content());

Or, if I have a WebTML form, whose data I want transferred to the targeted document, I could just do:


This does actually the same as default action $store when presenting a WebTML form with an existing documents data.

You should always prefer using the HDBModel methods to create/update/delete contents defined by HDBModel, unless where it is explicitly forbidden (there is only one situation in event scripts discussed later). While it sometimes may be possible to treat HDBModel content with the usual WGAPI methods (db().createContent(),, doc.remove()) only the HDBModel methods mentioned above ensure, that all HDBModel functionality is active and the integrity of the data is kept.

Other methods on the HDBModel object let you retrieve documents regarding defined relations, identifying document type and ID and the such. Browse the TMLScript reference of the HDBModel object to explore them.

Table of contents: