\CouchbaseViewQuery

Represents regular Couchbase Map/Reduce View query

Summary

Methods
Properties
Constants
from()
fromSpatial()
encode()
limit()
skip()
consistency()
order()
reduce()
group()
groupLevel()
key()
keys()
range()
idRange()
custom()
No public properties found
UPDATE_BEFORE
UPDATE_NONE
UPDATE_AFTER
ORDER_ASCENDING
ORDER_DESCENDING
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

UPDATE_BEFORE

UPDATE_BEFORE

Force a view update before returning data

UPDATE_NONE

UPDATE_NONE

Allow stale views

UPDATE_AFTER

UPDATE_AFTER

Allow stale view, update view after it has been accessed.

ORDER_ASCENDING

ORDER_ASCENDING

ORDER_DESCENDING

ORDER_DESCENDING

Methods

from()

from(string  $designDocumentName, string  $viewName) : \Couchbase\ViewQuery

Creates a new Couchbase ViewQuery instance for performing a view query.

Parameters

string $designDocumentName

the name of the design document to query

string $viewName

the name of the view to query

Returns

\Couchbase\ViewQuery

fromSpatial()

fromSpatial(string  $designDocumentName, string  $viewName) : \Couchbase\SpatialViewQuery

Creates a new Couchbase ViewQuery instance for performing a spatial query.

Parameters

string $designDocumentName

the name of the design document to query

string $viewName

the name of the view to query

Returns

\Couchbase\SpatialViewQuery

encode()

encode() : array

Returns associative array, representing the View query.

Returns

array —

object which is ready to be serialized.

limit()

limit(integer  $limit) : \Couchbase\ViewQuery

Limits the result set to a specified number rows.

Parameters

integer $limit

maximum number of records in the response

Returns

\Couchbase\ViewQuery

skip()

skip(integer  $skip) : \Couchbase\ViewQuery

Skips a number o records rom the beginning of the result set

Parameters

integer $skip

number of records to skip

Returns

\Couchbase\ViewQuery

consistency()

consistency(integer  $consistency) : \Couchbase\ViewQuery

Specifies the mode of updating to perorm before and after executing the query

Parameters

integer $consistency

use constants UPDATE_BEFORE, UPDATE_NONE, UPDATE_AFTER

Returns

\Couchbase\ViewQuery

order()

order(integer  $order) : \Couchbase\ViewQuery

Orders the results by key as specified

Parameters

integer $order

use contstants ORDER_ASCENDING, ORDER_DESCENDING

Returns

\Couchbase\ViewQuery

reduce()

reduce(boolean  $reduce) : \Couchbase\ViewQuery

Specifies whether the reduction function should be applied to results of the query.

Parameters

boolean $reduce

Returns

\Couchbase\ViewQuery

group()

group(boolean  $group) : \Couchbase\ViewQuery

Group the results using the reduce function to a group or single row.

Important: this setter and groupLevel should not be used together in the same ViewQuery. It is sufficient to only set the grouping level only and use this setter in cases where you always want the highest group level implictly.

Parameters

boolean $group

Returns

\Couchbase\ViewQuery

groupLevel()

groupLevel(integer  $groupLevel) : \Couchbase\ViewQuery

Specify the group level to be used.

Important: group() and this setter should not be used together in the same ViewQuery. It is sufficient to only use this setter and use group() in cases where you always want the highest group level implictly.

Parameters

integer $groupLevel

the number of elements in the keys to use

Returns

\Couchbase\ViewQuery

key()

key(mixed  $key) : \Couchbase\ViewQuery

Restict results of the query to the specified key

Parameters

mixed $key

key

Returns

\Couchbase\ViewQuery

keys()

keys(array  $keys) : \Couchbase\ViewQuery

Restict results of the query to the specified set of keys

Parameters

array $keys

set of keys

Returns

\Couchbase\ViewQuery

range()

range(mixed  $startKey, mixed  $endKey, boolean  $inclusiveEnd = false) : \Couchbase\ViewQuery

Specifies a range of the keys to return from the index.

Parameters

mixed $startKey
mixed $endKey
boolean $inclusiveEnd

Returns

\Couchbase\ViewQuery

idRange()

idRange(string  $startKeyDocumentId, string  $endKeyDocumentId) : \Couchbase\ViewQuery

Specifies start and end document IDs in addition to range limits.

This might be needed for more precise pagination with a lot of documents with the same key selected into the same page.

Parameters

string $startKeyDocumentId

document ID

string $endKeyDocumentId

document ID

Returns

\Couchbase\ViewQuery

custom()

custom(array  $customParameters) : \Couchbase\ViewQuery

Specifies custom options to pass to the server.

Note that these options are expected to be already encoded.

Parameters

array $customParameters

parameters

Returns

\Couchbase\ViewQuery