You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

range()

Usage

range(start, end)
range(start, end, includeStart, includeEnd)

Description
Returns a search predicate to specify value ranges, greater and less-than searches in find() and search() functions. The first two parameters represent the first and the last element of the desired query range. Both start and end of the range can be set to null to allow the use of range() for <, <=. > and >= queries.

There are two optional boolean parameters, includeStart and includeEnd that control whether the search range should include or exclude the endpoints of the interval.

Examples

${find('Project', 'taskCount', range(0, 10))}
${find('Project', 'taskCount', range(0, 10, true, false))}
${find('Project', 'taskCount', range(0, 10, false, false))}

Server-side JavaScript Examples

Structr.find('Project').forEach(p => Structr.print(p.index + ", "));
=> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 

Structr.find('Project', { index: Structr.range(2, 5) }).forEach(p => Structr.print(p.index + ", "));
=> 2, 3, 4, 5, 

Structr.find('Project', { index: Structr.range(2, 5, false) }).forEach(p => Structr.print(p.index + ", "));
=> 3, 4, 5, 

Structr.find('Project', { index: Structr.range(2, 5, false, false) }).forEach(p => Structr.print(p.index + ", "));
=> 3, 4,

Search results for "range()"

range()

Returns a search predicate to specify value ranges, greater and less-than searches in find() and search() functions. The first two parameters represent the first and the last element of the desired query range. Both start and end of the range can be set to null to allow the use of range() for <, <=. > and >= queries.
There are two optional boolean parameters, includeStart and includeEnd that control whether the search range should include or exclude the endpoints of the interval.

range(start, end)
range(start, end, includeStart, includeEnd)