class Query extends AbstractQuery (View source)

Query class.

Properties

protected DesignDocument $doc from AbstractQuery
protected string $designDocumentName from AbstractQuery
protected string $viewName from AbstractQuery
protected string $databaseName from AbstractQuery
protected Client $client from AbstractQuery
protected array $params from AbstractQuery

Methods

__construct(Client $client, $databaseName, $designDocName, $viewName, DesignDocument $doc = null)

No description

mixed
getParameter(string $key)

No description

getHttpQuery()

Encode HTTP Query String for View correctly with the following rules in mind.

execute()

Query the view with the current params.

doExecute()

No description

createResult($response)

No description

void
createDesignDocument()

Create non existing view.

setKey(string|array $val)

Find key in view.

setKeys(array $values)

Find keys in the view.

setStartKey(string $val)

Set starting key to query view for.

setEndKey(string $val)

Set ending key to query view for.

setStartKeyDocId(string $val)

Document id to start with.

setEndKeyDocId(string $val)

Last document id to include in the output.

setLimit(int $val)

Limit the number of documents in the output.

setSkip(int $val)

Skip n number of documents.

setStale(bool $flag)

If stale=ok is set CouchDB will not refresh the view even if it is stalled.

setDescending(bool $flag)

reverse the output.

setGroup(bool $flag)

The group option controls whether the reduce function reduces to a set of distinct keys or to a single result row.

setGroupLevel($level)

No description

setReduce(bool $flag)

Use the reduce function of the view. It defaults to true, if a reduce function is defined and to false otherwise.

setInclusiveEnd(bool $flag)

Controls whether the endkey is included in the result. It defaults to true.

setIncludeDocs(bool $flag)

Automatically fetch and include the document which emitted each view entry.

Details

__construct(Client $client, $databaseName, $designDocName, $viewName, DesignDocument $doc = null)

Parameters

Client $client
$databaseName
$designDocName
$viewName
DesignDocument $doc

mixed getParameter(string $key)

Parameters

string $key

Return Value

mixed

protected getHttpQuery()

Encode HTTP Query String for View correctly with the following rules in mind.

  1. Params "key", "keys", "startkey" or "endkey" must be json encoded.
  2. Booleans must be converted to "true" or "false"

Result execute()

Query the view with the current params.

Return Value

Result

protected doExecute()

protected Result createResult($response)

Parameters

$response

Return Value

Result

void createDesignDocument()

Create non existing view.

Return Value

void

Exceptions

JsonDecodeException
Exception

Query setKey(string|array $val)

Find key in view.

Parameters

string|array $val

Return Value

Query

Query setKeys(array $values)

Find keys in the view.

Parameters

array $values

Return Value

Query

Query setStartKey(string $val)

Set starting key to query view for.

Parameters

string $val

Return Value

Query

Query setEndKey(string $val)

Set ending key to query view for.

Parameters

string $val

Return Value

Query

Query setStartKeyDocId(string $val)

Document id to start with.

Parameters

string $val

Return Value

Query

Query setEndKeyDocId(string $val)

Last document id to include in the output.

Parameters

string $val

Return Value

Query

Query setLimit(int $val)

Limit the number of documents in the output.

Parameters

int $val

Return Value

Query

Query setSkip(int $val)

Skip n number of documents.

Parameters

int $val

Return Value

Query

Query setStale(bool $flag)

If stale=ok is set CouchDB will not refresh the view even if it is stalled.

Parameters

bool $flag

Return Value

Query

Query setDescending(bool $flag)

reverse the output.

Parameters

bool $flag

Return Value

Query

Query setGroup(bool $flag)

The group option controls whether the reduce function reduces to a set of distinct keys or to a single result row.

Parameters

bool $flag

Return Value

Query

setGroupLevel($level)

Parameters

$level

Query setReduce(bool $flag)

Use the reduce function of the view. It defaults to true, if a reduce function is defined and to false otherwise.

Parameters

bool $flag

Return Value

Query

Query setInclusiveEnd(bool $flag)

Controls whether the endkey is included in the result. It defaults to true.

Parameters

bool $flag

Return Value

Query

Query setIncludeDocs(bool $flag)

Automatically fetch and include the document which emitted each view entry.

Parameters

bool $flag

Return Value

Query