-
Notifications
You must be signed in to change notification settings - Fork 0
Adapter: Mass methods
Bulk operations over many items. All return {processed: number}.
See also (AWS JS SDK v3):
BatchWriteCommand·BatchGetCommand· BatchWriteItem API · BatchGetItem API. Vocabulary: Concepts.
| Method | Strategy |
|---|---|
putItems(items, options?) |
'native' (default) → BatchWriteItem. 'sequential' → individual Put per item. |
deleteByKeys(keys, options?) |
Same dual strategy. |
deleteListByParams(params, options?) |
Read keys via scan/query, delete in batches. |
cloneByKeys(keys, mapFn?, options?) |
BatchGet + BatchWrite. |
cloneListByParams(params, mapFn?, options?) |
Read items via scan/query, write transformed copies. |
moveByKeys(keys, mapFn?, options?) |
BatchGet + paired put/delete chunks (12 puts + 12 deletes per BatchWrite). |
moveListByParams(params, mapFn?, options?) |
Read via scan/query, paired put/delete chunks. |
interface MassOptions {
strategy?: 'native' | 'sequential';
params?: object;
}cloneByKeys, cloneListByParams, moveByKeys, moveListByParams all accept an optional mapFn. When omitted, the item is copied/moved as-is (the default is the identity function, x => x). Without a mapFn, clone-to-same-key throws ConditionalCheckFailedException (the Adapter's default write path adds an existence condition); the common case is to supply a mapFn that rewrites the key or some attribute so the destination is distinct. See Adapter: CRUD methods clone / move for the single-item version of the same pattern.
// Bulk load
const r = await adapter.putItems(planets);
// → {processed: 61}
// Delete by keys
await adapter.deleteByKeys([{name: 'Hoth'}, {name: 'Bespin'}]);
// Delete via filter
await adapter.deleteListByParams({
TableName: 'planets',
FilterExpression: 'climate = :c',
ExpressionAttributeValues: {':c': 'frozen'}
});
// Clone with overlay — mapFn rewrites the key + transforms an attribute
await adapter.cloneByKeys(
[{name: 'Tatooine'}, {name: 'Hoth'}],
item => ({...item, name: item.name + '-copy', diameter: item.diameter * 2})
);
// Move (rename) under a transform — atomic put + delete within each chunk
await adapter.moveByKeys(
[{name: 'old-name'}],
item => ({...item, name: 'new-name'})
);The mass methods compose on top of dynamodb-toolkit/mass helpers (writeList, deleteList, copyList, moveList, …) plus the dynamodb-toolkit/batch chunkers. See Mass operations and Batch and transactions for the standalone API.
-
native— default. Maximizes throughput by batching and letslib-dynamodb'sUnprocessedItemsretry handle backpressure. Loses per-item conditions (BatchWriteItemdoesn't support them). -
sequential— slower; one Command per item. Each item flows through the full single-op path includingcheckConsistency, so per-item transactions and conditions work as expected. Use when you need per-item validation or can't tolerate partial-batch failures.
Start here
- Getting started
- Concepts
- Key and field design
- Compatibility
- Migration: v2 to v3
- SDK v2 to v3 cheat sheet
Guides
- Hierarchical data walkthrough
- Key expression patterns
- Multi-type tables
- Pagination
- Mass operation semantics
- URL schema design
Adapter
- Adapter
- Constructor options
- CRUD methods
- Mass methods
- Batch builders
- Hooks
- Raw marker
- Indirect indices
- Transaction auto-upgrade
Expression builders
Batch / transactions / mass / paths
REST surface
Framework adapters
Recipes
- Recipes index
- List records of a tier
- Per-tier sparse GSI markers
- Tier within a partition
- Reservation with auto-release
- Keys-only GSI, runtime projection
- Cascade subtree operations
- Querying subtrees with buildKey
- Filter URL grammar
- Text search
- Provisioning workflow
- Resumable mass operations
History