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> ErrorMode :number

Enumeration for specifying on_error behaviour.

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

Continues querying when an error occurs.

STOP number 2

Stops and errors query when an error occurs.


<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)

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)

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)

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

full_set(full_set)

Flag to request a view request accross all nodes in the case of a development view.

Parameters:
Name Type Description
full_set boolean
Since:
  • 2.0.3 (stability: committed)
Returns:
Type
ViewQuery

group(group)

Specifies whether to preform grouping during view execution.

Parameters:
Name Type Description
group boolean
Since:
  • 2.0.3 (stability: committed)
Returns:
Type
ViewQuery

group_level(group_level)

Specifies the level at which to perform view grouping.

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

id_range(start, end)

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

include_docs(include_docs)

Flag to request a view request include the full document value.

Parameters:
Name Type Description
include_docs boolean
Since:
  • 2.0.8 (stability: committed)
Returns:
Type
ViewQuery

key(key)

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)

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)

Specifies the maximum number of results to return.

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

on_error(mode)

Sets the error handling mode for this query.

Parameters:
Name Type Description
mode ViewQuery.ErrorMode
Since:
  • 2.0.3 (stability: committed)
Returns:
Type
ViewQuery

order(order)

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])

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 | Array.<string> | undefined
end string | Array.<string> | undefined
inclusive_end boolean <optional>
Since:
  • 2.0.0 (stability: committed)
Returns:
Type
ViewQuery

reduce(reduce)

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)

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)

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