"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const logger_1 = require("../../../logger/logger");
const mapper_1 = require("../../../mapper");
const prepare_and_add_update_expressions_function_1 = require("../../expression/prepare-and-add-update-expressions.function");
const request_expression_builder_1 = require("../../expression/request-expression-builder");
const write_request_1 = require("../write.request");
class UpdateRequest extends write_request_1.WriteRequest {
    constructor(dynamoRx, modelClazz, partitionKey, sortKey) {
        super(dynamoRx, modelClazz);
        this.logger = logger_1.createLogger('dynamo.request.UpdateRequest', modelClazz);
        this.params.Key = mapper_1.createKeyAttributes(this.metadata, partitionKey, sortKey);
    }
    updateAttribute(attributePath) {
        return request_expression_builder_1.addUpdate(attributePath, this, this.metadata);
    }
    operations(...updateDefFns) {
        prepare_and_add_update_expressions_function_1.prepareAndAddUpdateExpressions(this.metadata, this.params, updateDefFns);
        return this;
    }
    execFullResponse() {
        this.logger.debug('request', this.params);
        return this.dynamoRx.updateItem(this.params).pipe(operators_1.tap(response => this.logger.debug('response', response)));
    }
}
exports.UpdateRequest = UpdateRequest;
//# sourceMappingURL=update.request.js.map