dynamodb-toolbox
Version:
Lightweight and type-safe query builder for DynamoDB and TypeScript.
28 lines (27 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BatchDeleteRequest = void 0;
const index_js_1 = require("../../../entity/actions/parse/index.js");
const index_js_2 = require("../../../entity/index.js");
const index_js_3 = require("../../../errors/index.js");
const constants_js_1 = require("./constants.js");
class BatchDeleteRequest extends index_js_2.EntityAction {
constructor(entity, key) {
super(entity);
this[constants_js_1.$key] = key;
}
key(nextKey) {
return new BatchDeleteRequest(this.entity, nextKey);
}
params() {
if (!this[constants_js_1.$key]) {
throw new index_js_3.DynamoDBToolboxError('actions.incompleteAction', {
message: 'DeleteItemCommand incomplete: Missing "key" property'
});
}
const { key } = this.entity.build(index_js_1.EntityParser).parse(this[constants_js_1.$key], { mode: 'key' });
return { DeleteRequest: { Key: key } };
}
}
exports.BatchDeleteRequest = BatchDeleteRequest;
BatchDeleteRequest.actionName = 'batchDelete';