OpenWGA 7.11 - TMLScript reference


Object:

QueryResult

Description

Represents a CollectionResult carrying all resulting data of an executed query.

Besides the actual set which carries all the resulting documents this object can also be used to find out about other information of the query result, like the actually executed full query, whether the query was served from WGAPI query cache etc.

Retrieval Database.query()
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Inherits from object CollectionResult
Properties and methods
Name Purpose
contains(context) inherited

contains(ctx) takes a WGContext object as parameter and checks if this context is contained in the collection result.

each(function) inherited Applies a function to each element of the collection result.
exclude(context) inherited Filters out the given document from the collection result
executionTime Returns the time the query took to execute in milliseconds
filter(function) inherited Applies a filter to the collection result
firstResult inherited Returns the first result document of the collection
firstResultContent inherited Returns the first result document of the collection as WGAPI content object
fullQuery Returns the full query that was executed
getPage([offset,] size) inherited Returns a page of result documents
getSingleValue(itemName) inherited Returns the value of an item from the first result document of this collection
groupMap(function [,descending]) inherited This method creates and returns a sorted map keyed by the return value of a user defined function where its value is a list of TMLContext objects evaluating to the same key.
isEmpty() inherited Tests if the result has at last one elements, the current user can read.
map(function) inherited map(function) takes a JS-Function as parameter. This function is called for each result entry with the TMLContext as parameter and must return some value. The return value of map() is a list of all mapped values.
originalResult inherited Returns the original QueryResult or NavigatorResult of this collection result
outputParams Returns all output parameters of the query
servedFromCache Returns if the query result was served from the WGAPI query cache
set Returns the WGAPI result set object of the query containing the resulting contents
size inherited Returns the number of result documents in the collection
skip(size) inherited Skips the first documents in the current collection result
Examples

Iterating over the results of a query result - variable "qs" - using an Iterator:

var qr = WGA.app().query("hql", "content.structentry.contenttype.name='standard'");

for (cx in Iterator(qr)) {

  list.add(cx.TITLE);

}

More examples on object CollectionResult.