OpenWGA 7.0 - TMLScript reference


Object:

ResultSet

Description

The ResultSet object represents the returned documents from a query of any type.

The ResultSet may be regarded a collection like Lists and Lookup tables. But unlike these a ResultSet does not need to instantly load all the data that it is able to return. It instead is capable of only loading the set of data that is requested on its methods. This makes it a suitable for treating large result sets effectively, as only the documents that are requested are loaded.

A ResultSet is iterable in JavaScript, so it may be used as parameter for the JavaScript function Iterator(). The returned objects are WGAPI WGContent objects representing the rest set contents.

A ResultSet may be returned by a <tml:script> tag as tag result and then picked up by a <tml:foreach> tag to iterate over the values.

Retrieval

QueryResult.set

HDBModel.getRelationSources()

HDBModel.getRelationTargets()

Database queries for method query() of WGAPI object WGDatabase

Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Properties and methods
Name Purpose
getContentList([start, length]) Extracts a list of content documents from the set
results() Returns the maximum number of documents that this result set may return
Examples

Using a ResultSet object with JavaScript iterator:

var resultSet = WGA.app().query("lucene", "WGA").set();

for (c in Iterator(resultSet)) {

  addWarning(c.title);

}


Returning a ResultSet as tag result of <tml:script>, then pick that up with a <tml:foreach> tag for iterating:

<tml:script id="thesearch" output="none">

return WGA.app().query("lucene", "WGA").set()

</tml:script>


<tml:foreach sourcetag="thesearch">

  <tml:meta name="title"/><br>

</tml:foreach>