UNPKG

dynamodb-toolbox

Version:

Lightweight and type-safe query builder for DynamoDB and TypeScript.

24 lines (23 loc) 875 B
import { EntityParser } from '../../../entity/actions/parse/index.js'; import { EntityAction } from '../../../entity/index.js'; import { DynamoDBToolboxError } from '../../../errors/index.js'; import { $key } from './constants.js'; export class BatchDeleteRequest extends EntityAction { constructor(entity, key) { super(entity); this[$key] = key; } key(nextKey) { return new BatchDeleteRequest(this.entity, nextKey); } params() { if (!this[$key]) { throw new DynamoDBToolboxError('actions.incompleteAction', { message: 'DeleteItemCommand incomplete: Missing "key" property' }); } const { key } = this.entity.build(EntityParser).parse(this[$key], { mode: 'key' }); return { DeleteRequest: { Key: key } }; } } BatchDeleteRequest.actionName = 'batchDelete';