Collection
in package
implements
CollectionInterface
Collection is an object containing functionality for performing KeyValue operations against the server.
Interfaces, Classes, Traits and Enums
Table of Contents
- $bucketName : string
- $core : resource
- $name : string
- $scopeName : string
- binary() : BinaryCollection
- Creates and returns a BinaryCollection object for use with binary type documents.
- bucketName() : string
- Get the name of the bucket.
- exists() : ExistsResult
- Checks if a document exists on the server.
- get() : GetResult
- Gets a document from the server.
- getAllReplicas() : array<string|int, mixed>
- Gets a document from the active server and all replica servers in the cluster.
- getAndLock() : GetResult
- Gets a document from the server, locking the document so that no other processes can perform mutations against it.
- getAndTouch() : GetResult
- Gets a document from the server and simultaneously updates its expiry time.
- getAnyReplica() : GetReplicaResult
- Gets a document from any replica server in the cluster.
- getMulti() : array<string|int, GetResult>
- Retrieves a group of documents. If the document does not exist, it will not raise an exception, but rather fill non-null value in error() property of the corresponding result object.
- insert() : MutationResult
- Inserts a document if it doesn't exist, errors if it does exist.
- lookupIn() : LookupInResult
- Performs a set of subdocument lookup operations against the document.
- lookupInAllReplicas() : array<string|int, mixed>
- Performs a set of subdocument lookup operations against the document from the active server and all replicas in the cluster.
- lookupInAnyReplica() : LookupInReplicaResult
- Performs a set of subdocument lookup operations against the document from any replica server in the cluster.
- mutateIn() : MutateInResult
- Performs a set of subdocument lookup operations against the document.
- name() : string
- Get the name of the collection.
- queryIndexes() : CollectionQueryIndexManager
- Creates a new manager object for managing N1QL query indexes at the collection level
- remove() : MutationResult
- Removes a document.
- removeMulti() : array<string|int, MutationResult>
- Removes a group of documents. If second element of the entry (CAS) is null, then the operation will remove the document unconditionally.
- replace() : MutationResult
- Replaces a document if it exists, errors if it doesn't exist.
- scan() : ScanResults
- Performs a key-value scan operation
- scopeName() : string
- Get the name of the scope.
- touch() : MutationResult
- Touches a document, setting a new expiry time.
- unlock() : Result
- Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.
- upsert() : MutationResult
- Creates a document if it doesn't exist, otherwise updates it.
- upsertMulti() : array<string|int, MutationResult>
- Creates a group of documents if they don't exist, otherwise updates them.
Properties
$bucketName
private
string
$bucketName
$core
private
resource
$core
$name
private
string
$name
$scopeName
private
string
$scopeName
Methods
binary()
Creates and returns a BinaryCollection object for use with binary type documents.
public
binary() : BinaryCollection
Tags
Return values
BinaryCollection —bucketName()
Get the name of the bucket.
public
bucketName() : string
Tags
Return values
string —exists()
Checks if a document exists on the server.
public
exists(string $id[, ExistsOptions|null $options = null ]) : ExistsResult
Parameters
- $id : string
-
the key of the document to check if exists
- $options : ExistsOptions|null = null
-
the options to use for the operation
Tags
Return values
ExistsResult —get()
Gets a document from the server.
public
get(string $id[, GetOptions|null $options = null ]) : GetResult
This can take 3 paths:
- a standard full document fetch,
- a subdocument full document fetch also fetching document expiry (when withExpiry is set),
- or a subdocument fetch (when projections are used).
Parameters
- $id : string
-
the key of the document to fetch
- $options : GetOptions|null = null
-
the options to use for the operation
Tags
Return values
GetResult —getAllReplicas()
Gets a document from the active server and all replica servers in the cluster.
public
getAllReplicas(string $id[, GetAllReplicasOptions|null $options = null ]) : array<string|int, mixed>
Returns an array of documents, one per server.
Parameters
- $id : string
-
the key of the document
- $options : GetAllReplicasOptions|null = null
-
the options to use for the operation
Tags
Return values
array<string|int, mixed> —getAndLock()
Gets a document from the server, locking the document so that no other processes can perform mutations against it.
public
getAndLock(string $id, int $lockTimeSeconds[, GetAndLockOptions|null $options = null ]) : GetResult
Parameters
- $id : string
-
the key of the document to get
- $lockTimeSeconds : int
-
the length of time to lock the document in seconds
- $options : GetAndLockOptions|null = null
-
the options to use for the operation
Tags
Return values
GetResult —getAndTouch()
Gets a document from the server and simultaneously updates its expiry time.
public
getAndTouch(string $id, int|DateTimeInterface $expiry[, GetAndTouchOptions|null $options = null ]) : GetResult
Parameters
- $id : string
-
the key of the document
- $expiry : int|DateTimeInterface
-
the length of time to update the expiry to in seconds, or epoch timestamp
- $options : GetAndTouchOptions|null = null
-
the options to use for the operation
Tags
Return values
GetResult —getAnyReplica()
Gets a document from any replica server in the cluster.
public
getAnyReplica(string $id[, GetAnyReplicaOptions|null $options = null ]) : GetReplicaResult
Parameters
- $id : string
-
the key of the document
- $options : GetAnyReplicaOptions|null = null
-
the options to use for the operation
Tags
Return values
GetReplicaResult —getMulti()
Retrieves a group of documents. If the document does not exist, it will not raise an exception, but rather fill non-null value in error() property of the corresponding result object.
public
getMulti(array<string|int, mixed> $ids[, GetOptions|null $options = null ]) : array<string|int, GetResult>
Parameters
- $ids : array<string|int, mixed>
-
array of IDs, organized like this ["key1", "key2", ...]
- $options : GetOptions|null = null
-
the options to use for the operation
Tags
Return values
array<string|int, GetResult> —array of GetResult, one for each of the entries
insert()
Inserts a document if it doesn't exist, errors if it does exist.
public
insert(string $id, mixed $value[, InsertOptions|null $options = null ]) : MutationResult
Parameters
- $id : string
-
the key of the document
- $value : mixed
-
the value to use for the document
- $options : InsertOptions|null = null
-
the options to use for the operation
Tags
Return values
MutationResult —lookupIn()
Performs a set of subdocument lookup operations against the document.
public
lookupIn(string $id, array<string|int, LookupInSpec> $specs[, LookupInOptions|null $options = null ]) : LookupInResult
Parameters
- $id : string
-
the key of the document
- $specs : array<string|int, LookupInSpec>
-
the array of selectors to query against the document
- $options : LookupInOptions|null = null
-
the options to use for the operation
Tags
Return values
LookupInResult —lookupInAllReplicas()
Performs a set of subdocument lookup operations against the document from the active server and all replicas in the cluster.
public
lookupInAllReplicas(string $id, array<string|int, LookupInSpec> $specs[, LookupInAllReplicasOptions|null $options = null ]) : array<string|int, mixed>
Returns an array of LookupInReplicaResults, one per server.
Parameters
- $id : string
-
the key of the document
- $specs : array<string|int, LookupInSpec>
-
the array of selectors to query against the document
- $options : LookupInAllReplicasOptions|null = null
-
the options to use for the operation
Tags
Return values
array<string|int, mixed> —lookupInAnyReplica()
Performs a set of subdocument lookup operations against the document from any replica server in the cluster.
public
lookupInAnyReplica(string $id, array<string|int, LookupInSpec> $specs[, LookupInAnyReplicaOptions|null $options = null ]) : LookupInReplicaResult
Parameters
- $id : string
-
the key of the document
- $specs : array<string|int, LookupInSpec>
-
the array of selectors to query against the document
- $options : LookupInAnyReplicaOptions|null = null
-
the options to use for the operation
Tags
Return values
LookupInReplicaResult —mutateIn()
Performs a set of subdocument lookup operations against the document.
public
mutateIn(string $id, array<string|int, MutateInSpec> $specs[, MutateInOptions|null $options = null ]) : MutateInResult
Parameters
- $id : string
-
the key of the document
- $specs : array<string|int, MutateInSpec>
-
the array of modifications to perform against the document
- $options : MutateInOptions|null = null
-
the options to use for the operation
Tags
Return values
MutateInResult —name()
Get the name of the collection.
public
name() : string
Tags
Return values
string —queryIndexes()
Creates a new manager object for managing N1QL query indexes at the collection level
public
queryIndexes() : CollectionQueryIndexManager
Tags
Return values
CollectionQueryIndexManager —remove()
Removes a document.
public
remove(string $id[, RemoveOptions|null $options = null ]) : MutationResult
Parameters
- $id : string
-
the key of the document
- $options : RemoveOptions|null = null
-
the options to use for the operation
Tags
Return values
MutationResult —removeMulti()
Removes a group of documents. If second element of the entry (CAS) is null, then the operation will remove the document unconditionally.
public
removeMulti(array<string|int, mixed> $entries[, RemoveOptions|null $options = null ]) : array<string|int, MutationResult>
Parameters
- $entries : array<string|int, mixed>
-
array of arrays, organized like this [["key1", "encodedCas1"], ["key2", "encodedCas2"], ...] or ["key1", "key2", ...]
- $options : RemoveOptions|null = null
-
the options to use for the operation
Tags
Return values
array<string|int, MutationResult> —array of MutationResult, one for each of the entries
replace()
Replaces a document if it exists, errors if it doesn't exist.
public
replace(string $id, mixed $value[, ReplaceOptions|null $options = null ]) : MutationResult
Parameters
- $id : string
-
the key of the document
- $value : mixed
-
the value to use for the document
- $options : ReplaceOptions|null = null
-
the options to use for the operation
Tags
Return values
MutationResult —scan()
Performs a key-value scan operation
public
scan(ScanType $scanType[, ScanOptions|null $options = null ]) : ScanResults
Use this API for low concurrency batch queries where latency is not a critical as the system may have to scan a lot of documents to find the matching documents. For low latency range queries, it is recommended that you use SQL++ with the necessary indexes.
Parameters
- $scanType : ScanType
-
The type of scan to execute
- $options : ScanOptions|null = null
-
The options to use for the operation
Tags
Return values
ScanResults —Object containing iterator over the scan results
scopeName()
Get the name of the scope.
public
scopeName() : string
Tags
Return values
string —touch()
Touches a document, setting a new expiry time.
public
touch(string $id, int|DateTimeInterface $expiry[, TouchOptions|null $options = null ]) : MutationResult
Parameters
- $id : string
-
the key of the document
- $expiry : int|DateTimeInterface
-
the expiry time for the document in ms
- $options : TouchOptions|null = null
-
the options to use for the operation
Tags
Return values
MutationResult —unlock()
Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.
public
unlock(string $id, string $cas[, UnlockOptions|null $options = null ]) : Result
Parameters
- $id : string
-
the key of the document
- $cas : string
-
the current cas value of the document
- $options : UnlockOptions|null = null
-
the options to use for the operation
Tags
Return values
Result —upsert()
Creates a document if it doesn't exist, otherwise updates it.
public
upsert(string $id, mixed $value[, UpsertOptions|null $options = null ]) : MutationResult
Parameters
- $id : string
-
the key of the document
- $value : mixed
-
the value to use for the document
- $options : UpsertOptions|null = null
-
the options to use for the operation
Tags
Return values
MutationResult —upsertMulti()
Creates a group of documents if they don't exist, otherwise updates them.
public
upsertMulti(array<string|int, mixed> $entries[, UpsertOptions|null $options = null ]) : array<string|int, MutationResult>
Parameters
- $entries : array<string|int, mixed>
-
array of arrays, organized like this [["key1", $value1], ["key2", $value2], ...]
- $options : UpsertOptions|null = null
-
the options to use for the operation
Tags
Return values
array<string|int, MutationResult> —array of MutationResult, one for each of the entries