Global

Methods

makeItemString(modelCls, _id, _skopt)

Returns a string which uniquely identifies an item.
Parameters:
Name Type Attributes Description
modelCls Model the Model for the item
_id string the item's partition key
_sk string <optional>
the item's sort key

Type Definitions

FieldOptions

Properties:
Name Type Attributes Default Description
keyType 'PARTITION' | 'SORT' <optional>
If specified, the field is a key. Use 'PARTITION' for a partition key. Use 'SORT' for a sort key. When keyType is specified, other options are forced to be { optional: false, immutable: true, default: undefined }. If user supplied values that conflicts with those values, InvalidOptionsError will be thrown.
optional Boolean <optional>
false If field can be left undefined.
immutable Boolean <optional>
false If field can be changed again after value is set to anything except undefined.
default * <optional>
Default value to use. IMPORTANT: Value is deeply copied, so additional modifications to the parameter will not reflect in the field.
schema schema <optional>
An optional JSON schema to validate Field's value.

GetParams

Parameters for fetching a model and options to control how a model is fetched from database.
Properties:
Name Type Attributes Default Description
inconsistentRead Boolean <optional>
false If true, model is read with strong consistency, else the read is eventually consistent.
createIfMissing Boolean <optional>
false If true, a model is returned regardless of whether the model exists on server. This behavior is the same as calling create when get(..., { createIfMissing: false }) returns undefined
* * <optional>
Besides the predefined options, custom key-value pairs can be added. These values will be made available to the Model's constructor as an argument.

TransactionOptions

Options for running a transaction.
Properties:
Name Type Attributes Default Description
readOnly Boolean <optional>
false whether writes are allowed
retries Number <optional>
3 The number of times to retry after the initial attempt fails.
initialBackoff Number <optional>
500 In milliseconds, delay after the first attempt fails and before first retry happens.
maxBackoff Number <optional>
10000 In milliseconds, max delay between retries. Must be larger than 200.
cacheModels Boolean <optional>
false Whether to cache models already retrieved from the database. When off, getting a model with the same key the second time in the same transaction results in an error. When on, `get`ting the same key simply returns the cached model. Previous modifications done to the model are reflected in the returned model. If the model key was used in some API other than "get", an error will result.