OpenWGA 7.0 - TMLScript reference


Object:

CollectionResult

Description

Represents an object carrying all resulting data of a document collection.

This is the parent class for objects QueryResult and NavigatorResult which represent collection results of a query or navigator respectively, defining shared functionality of both. A CollectionResult is also created by methods that modify an existing collection result by filtering it or skipping its first results.

Methods that create new CollectionResult objects with modified versions of the original CollectionResult, like filter() and skip(), may be freely cascaded. So you can apply multiple filters and do multiple skips on a collection result.

A CollectionResult is iterable in JavaScript, so it may be used as parameter for the JavaScript function Iterator(). The returned objects are TMLContext objects for the result contents.
Retrieval

CollectionResult.filter()

CollectionResult.skip()

CollectionResult.exclude()

Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Properties and methods
Name Purpose
exclude(context) Filters out the given document from the collection result
filter(function) Applies a filter to the collection result
getPage([offset,] length) Returns a page of result documents
originalResult Returns the original QueryResult or NavigatorResult of this collection result
size Returns the number of result documents in the collection
skip(size) Skips the first documents in the current collection result
Examples

Iterating over a CollectionResult, actually a NavigatorResult here, using a JavaScript iterator. The variable cx is filled with TMLContext objects pointing to the result documents:

for (cx in Iterator(WGA.nav().children())) {

  log.info(cx.TITLE);

}

An example of creating CollectionResults with special modifications in a cascaded way. FIrst we implement a filter to exclude documents being older than 1 month, then we skip the first 10 documents. Finally we retrieve a collection page of 5 documents, being the first 5 documents of the collection which a) are behind the first 10 documents and b) are modified in the recent month:

var theFilter = function (cx) cx.LASTMODIFIED > WGA.modifyDate(WGA.createDate(), "M", -1);

var nav = WGA.nav().children().filter(theFilter).skip(10);

var page = nav.getPage(5);