Methods
-
makeItemString(modelCls, _id, _skopt)
-
Returns a string which uniquely identifies an item.
Parameters:
Name Type Attributes Description modelClsModel the Model for the item _idstring the item's partition key _skstring <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. optionalBoolean <optional>
false If field can be left undefined. immutableBoolean <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. schemaschema <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 inconsistentReadBoolean <optional>
false If true, model is read with strong consistency, else the read is eventually consistent. createIfMissingBoolean <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 readOnlyBoolean <optional>
false whether writes are allowed retriesNumber <optional>
3 The number of times to retry after the initial attempt fails. initialBackoffNumber <optional>
500 In milliseconds, delay after the first attempt fails and before first retry happens. maxBackoffNumber <optional>
10000 In milliseconds, max delay between retries. Must be larger than 200. cacheModelsBoolean <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.