-
-
Runs a function in transaction, using specified parameters.
If a non-retryable error is thrown while running the transaction, it will
be re-raised.
Parameters:
Name |
Type |
Attributes |
Description |
options |
TransactionOptions
|
<optional>
|
|
func |
function
|
|
the closure to run. |
Example
// Can be called in 2 ways:
Transaction.run(async (tx) => {
// Do something
})
// Or
Transaction.run({ retryCount: 2 }, async (tx) => {
// Do something
})
-
-
Gets multiple items using DynamoDB's batchGetItems API.
Parameters:
Name |
Type |
Description |
keys |
Array.<Key>
|
A list of keys to get. |
params |
GetParams
|
Params used to get items, all items will be
fetched using the same params. |
-
-
Get an item using DynamoDB's getItem API.
Parameters:
Name |
Type |
Description |
key |
Key
|
A key for the item |
params |
GetParams
|
Params for how to get the item |
-
-
Gets multiple items using DynamoDB's transactGetItems API.
Parameters:
Name |
Type |
Description |
keys |
Array.<Key>
|
A list of keys to get. |
params |
GetParams
|
Params used to get items, all items will be
fetched using the same params. |
-
-
Creates a model without accessing DB. Write will make sure the item does
not exist.
Parameters:
Name |
Type |
Description |
Cls |
Model
|
A Model class. |
data |
CompositeID
|
Object
|
A superset of CompositeID of the model,
plus any data for Fields on the Model. |
-
-
Creates or puts an item without reading from DB.
It differs from update in that:
a) If item doesn't exists, a new item is created in DB
b) If item does exists, fields present locally will overwrite values in
DB, fields absent locally will be removed from DB.
Parameters:
Name |
Type |
Description |
Cls |
Class
|
The model's class. |
original |
CompositeID
|
Object
|
A superset of CompositeID,
field's values. Non-key values are used for conditional locking |
updated |
Object
|
Final values for the model.
Values for every field in the model must be provided. Fields with
`undefined` value will be removed from DB. |
-
-
Deletes model(s) from database.
If a model is read from database, but it did not exist when deleting the
item, an exception is raised.
Parameters:
Name |
Type |
Attributes |
Description |
args |
List.<(Key|Model)>
|
<repeatable>
|
Keys and Models |
-
-
Enables model cache
-
-
Fetches model(s) from database.
This method supports 3 different signatures.
get(Cls, keyOrDataValues, params)
get(Key|Data, params)
get([Key|Data], params)
When only one items is fetched, DynamoDB's getItem API is called. Must use
a Key when createIfMissing is not true, and Data otherwise.
When a list of items is fetched:
If inconsistentRead is false (the default), DynamoDB's transactGetItems
API is called for a strongly consistent read. Transactional reads will
be slower than batched reads.
If inconsistentRead is true, DynamoDB's batchGetItems API is called.
Batched fetches are more efficient than calling get with 1 key many
times, since there is less HTTP request overhead. Batched fetches is
faster than transactional fetches, but provides a weaker consistency.
Parameters:
Name |
Type |
Attributes |
Description |
Cls |
Class
|
|
a Model class. |
key |
String
|
CompositeID
|
|
Key or keyValues |
params |
GetParams
|
<optional>
|
|
Returns:
- Model(s) associated with provided key
-
-
Return before and after snapshots of all relevant models.
-
-
Marks a transaction as read-only.
-
-
Create a handle for applications to query DB items.
Parameters:
Name |
Type |
Description |
ModelCls |
Model
|
A model class. |
params.options |
IteratorOptions
|
Iterator options |
-
-
Create a handle for applications to scan DB items.
Parameters:
Name |
Type |
Description |
ModelCls |
Model
|
A model class. |
params.options |
IteratorOptions
|
Iterator options |
-
-
Updates an item without reading from DB. If the item doesn't exist in DB,
ConditionCheckFailure will be thrown.
Parameters:
Name |
Type |
Description |
Cls |
Class
|
The model's class. |
original |
CompositeID
|
Object
|
A superset of CompositeID,
field's values. Used as conditions for the update |
updated |
Object
|
Updated fields for the item, without CompositeID
fields. |