Collection
Collection is an object containing functionality for performing KeyValue operations against the server.
Table of Contents
name() | Get the name of the collection. | string |
---|---|---|
get() | Gets a document from the server. | GetResult |
exists() | Checks if a document exists on the server. | ExistsResult |
getAndLock() | Gets a document from the server, locking the document so that no other processes can perform mutations against it. | GetResult |
getAndTouch() | Gets a document from the server and simultaneously updates its expiry time. | GetResult |
getAnyReplica() | Gets a document from any replica server in the cluster. | GetReplicaResult |
getAllReplicas() | Gets a document from the active server and all replica servers in the cluster. | array |
upsert() | Creates a document if it doesn't exist, otherwise updates it. | MutationResult |
insert() | Inserts a document if it doesn't exist, errors if it does exist. | MutationResult |
replace() | Replaces a document if it exists, errors if it doesn't exist. | MutationResult |
remove() | Removes a document. | MutationResult |
unlock() | Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes. | Result |
touch() | Touches a document, setting a new expiry time. | MutationResult |
lookupIn() | Performs a set of subdocument lookup operations against the document. | LookupInResult |
mutateIn() | Performs a set of subdocument lookup operations against the document. | MutateInResult |
binary() | Creates and returns a BinaryCollection object for use with binary type documents. | BinaryCollection |
Methods
name()
Get the name of the collection.
public
name(
)
: string
Return values
stringget()
Gets a document from the server.
public
get(
$id :
string
[, $options :
GetOptions
= 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
the options to use for the operation
Return values
GetResultexists()
Checks if a document exists on the server.
public
exists(
$id :
string
[, $options :
ExistsOptions
= null ]
)
: ExistsResult
Parameters
- $id : string
the key of the document to check if exists
- $options : ExistsOptions = null
the options to use for the operation
Return values
ExistsResultgetAndLock()
Gets a document from the server, locking the document so that no other processes can perform mutations against it.
public
getAndLock(
$id :
string
, $lockTime :
int
[, $options :
GetAndLockOptions
= null ]
)
: GetResult
Parameters
- $id : string
the key of the document to get
- $lockTime : int
the length of time to lock the document in ms
- $options : GetAndLockOptions = null
the options to use for the operation
Return values
GetResultgetAndTouch()
Gets a document from the server and simultaneously updates its expiry time.
public
getAndTouch(
$id :
string
, $expiry :
int
[, $options :
GetAndTouchOptions
= null ]
)
: GetResult
Parameters
- $id : string
the key of the document
- $expiry : int
the length of time to update the expiry to in ms
- $options : GetAndTouchOptions = null
the options to use for the operation
Return values
GetResultgetAnyReplica()
Gets a document from any replica server in the cluster.
public
getAnyReplica(
$id :
string
[, $options :
GetAnyReplicaOptions
= null ]
)
: GetReplicaResult
Parameters
- $id : string
the key of the document
- $options : GetAnyReplicaOptions = null
the options to use for the operation
Return values
GetReplicaResultgetAllReplicas()
Gets a document from the active server and all replica servers in the cluster.
public
getAllReplicas(
$id :
string
[, $options :
GetAllReplicasOptions
= null ]
)
: array
Returns an array of documents, one per server.
Parameters
- $id : string
the key of the document
- $options : GetAllReplicasOptions = null
the options to use for the operation
Return values
arrayupsert()
Creates a document if it doesn't exist, otherwise updates it.
public
upsert(
$id :
string
, $value :
mixed
[, $options :
UpsertOptions
= null ]
)
: MutationResult
Parameters
- $id : string
the key of the document
- $value : mixed
the value to use for the document
- $options : UpsertOptions = null
the options to use for the operation
Return values
MutationResultinsert()
Inserts a document if it doesn't exist, errors if it does exist.
public
insert(
$id :
string
, $value :
mixed
[, $options :
InsertOptions
= null ]
)
: MutationResult
Parameters
- $id : string
the key of the document
- $value : mixed
the value to use for the document
- $options : InsertOptions = null
the options to use for the operation
Return values
MutationResultreplace()
Replaces a document if it exists, errors if it doesn't exist.
public
replace(
$id :
string
, $value :
mixed
[, $options :
ReplaceOptions
= null ]
)
: MutationResult
Parameters
- $id : string
the key of the document
- $value : mixed
the value to use for the document
- $options : ReplaceOptions = null
the options to use for the operation
Return values
MutationResultremove()
Removes a document.
public
remove(
$id :
string
[, $options :
RemoveOptions
= null ]
)
: MutationResult
Parameters
- $id : string
the key of the document
- $options : RemoveOptions = null
the options to use for the operation
Return values
MutationResultunlock()
Unlocks a document which was locked using getAndLock. This frees the document to be modified by other processes.
public
unlock(
$id :
string
, $cas :
string
[, $options :
UnlockOptions
= null ]
)
: Result
Parameters
- $id : string
the key of the document
- $cas : string
the current cas value of the document
- $options : UnlockOptions = null
the options to use for the operation
Return values
Resulttouch()
Touches a document, setting a new expiry time.
public
touch(
$id :
string
, $expiry :
int
[, $options :
TouchOptions
= null ]
)
: MutationResult
Parameters
- $id : string
the key of the document
- $expiry : int
the expiry time for the document in ms
- $options : TouchOptions = null
the options to use for the operation
Return values
MutationResultlookupIn()
Performs a set of subdocument lookup operations against the document.
public
lookupIn(
$id :
string
, $specs :
array
[, $options :
LookupInOptions
= null ]
)
: LookupInResult
Parameters
- $id : string
the key of the document
- $specs : array
the LookupInSpecs to perform against the document
- $options : LookupInOptions = null
the options to use for the operation
Return values
LookupInResultmutateIn()
Performs a set of subdocument lookup operations against the document.
public
mutateIn(
$id :
string
, $specs :
array
[, $options :
MutateInOptions
= null ]
)
: MutateInResult
Parameters
- $id : string
the key of the document
- $specs : array
the MutateInSpecs to perform against the document
- $options : MutateInOptions = null
the options to use for the operation
Return values
MutateInResultbinary()
Creates and returns a BinaryCollection object for use with binary type documents.
public
binary(
)
: BinaryCollection