Class: ViewQuery

ViewQuery

<private> new ViewQuery()

Class for dynamically construction of view queries. This class should never be constructed directly, instead you should use ViewQuery.from to construct this object.

Since:
  • 2.0.1 (stability: committed)

Members

<static, readonly> Order :number

Enumeration for specifying view result ordering.

Type:
  • number
Properties:
Name Type Default Description
ASCENDING number 1

Orders with lower values first and higher values last.

DESCENDING number 2

Orders with higher values first and lower values last.

<static, readonly> Update :number

Enumeration for specifying view update semantics.

Type:
  • number
Properties:
Name Type Default Description
BEFORE number 1

Causes the view to be fully indexed before results are retrieved.

NONE number 2

Allows the index to stay in whatever state it is already in prior retrieval of the query results.

AFTER number 3

Forces the view to be indexed after the results of this query has been fetched.

Methods

<static> from(ddoc, name) → {ViewQuery}

Instantiates a ViewQuery object for the specified design document and view name.

Parameters:
Name Type Description
ddoc string

The design document to use.

name string

The view to use.

Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

custom(opts) → {ViewQuery}

Allows you to specify custom view options that may not be available though the fluent interface defined by this class.

Parameters:
Name Type Description
opts Object
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

from(ddoc, name) → {ViewQuery}

Specifies the design document and view name to use for this query.

Parameters:
Name Type Description
ddoc string

The design document to use.

name string

The view to use.

Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

group(group_level) → {ViewQuery}

Specifies at what level to perform result grouping. These levels map to indexes within the emitted key arrays. A value of -1 indicates to not perform any grouping.

Parameters:
Name Type Description
group_level number
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

id_range(start, end) → {ViewQuery}

Specifies a range of document id's to retrieve from the index.

Parameters:
Name Type Description
start string | undefined
end string | undefined
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

key(key) → {ViewQuery}

Specifies a specified key to retrieve from the index.

Parameters:
Name Type Description
key string
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

keys(keys) → {ViewQuery}

Specifies a list of keys you wish to retrieve from the index.

Parameters:
Name Type Description
keys Array.<string>
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

limit(limit) → {ViewQuery}

Specifies the maximum number of results to return.

Parameters:
Name Type Description
limit number
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

order(order) → {ViewQuery}

Specifies the desired ordering for the results.

Parameters:
Name Type Description
order ViewQuery.Order
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

range(start, end, inclusive_end) → {ViewQuery}

Specifies a range of keys to retrieve from the index. You may specify both a start and an end point and additionally specify whether or not the end value is inclusive or exclusive.

Parameters:
Name Type Argument Description
start string | undefined
end string | undefined
inclusive_end boolean <optional>
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

reduce(reduce) → {ViewQuery}

Specifies whether to execute the map-reduce reduce step.

Parameters:
Name Type Description
reduce boolean
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

skip(skip) → {ViewQuery}

Specifies how many results to skip from the beginning of the result set.

Parameters:
Name Type Description
skip number
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

stale(stale) → {ViewQuery}

Specifies how this query will affect view indexing, both before and after the query is executed.

Parameters:
Name Type Description
stale ViewQuery.Update

How to update the index.

Since:
  • 2.0.0 (stability: committed)
Default Value:
  • ViewQuery.Update.NONE
Returns:
Type
ViewQuery