dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
24 lines (23 loc) • 833 B
JavaScript
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 BatchGetRequest extends EntityAction {
constructor(entity, key) {
super(entity);
this[$key] = key;
}
key(nextKey) {
return new BatchGetRequest(this.entity, nextKey);
}
params() {
if (!this[$key]) {
throw new DynamoDBToolboxError('actions.incompleteAction', {
message: 'BatchGetRequest incomplete: Missing "key" property'
});
}
const { key } = this.entity.build(EntityParser).parse(this[$key], { mode: 'key' });
return key;
}
}
BatchGetRequest.actionName = 'batchGet';