dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
24 lines (23 loc) • 854 B
JavaScript
import { EntityParser } from '../../../entity/actions/parse/index.js';
import { EntityAction } from '../../../entity/index.js';
import { DynamoDBToolboxError } from '../../../errors/index.js';
import { $item } from './constants.js';
export class BatchPutRequest extends EntityAction {
constructor(entity, item) {
super(entity);
this[$item] = item;
}
item(nextItem) {
return new BatchPutRequest(this.entity, nextItem);
}
params() {
if (!this[$item]) {
throw new DynamoDBToolboxError('actions.incompleteAction', {
message: 'BatchPutRequest incomplete: Missing "item" property'
});
}
const { item } = this.entity.build(EntityParser).parse(this[$item]);
return { PutRequest: { Item: item } };
}
}
BatchPutRequest.actionName = 'batchPut';