"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const operators_1 = require("rxjs/operators");
const logical_operator_1 = require("../expression/logical-operator");
const param_util_1 = require("../expression/param-util");
const request_expression_builder_1 = require("../expression/request-expression-builder");
const standard_request_1 = require("./standard.request");
/**
 * base class for all basic write request classes (DeleteItem, PutItem, UpdateItem
 */
class WriteRequest extends standard_request_1.StandardRequest {
    constructor(dynamoRx, modelClazz) {
        super(dynamoRx, modelClazz);
    }
    returnItemCollectionMetrics(returnItemCollectionMetrics) {
        this.params.ReturnItemCollectionMetrics = returnItemCollectionMetrics;
        return this;
    }
    onlyIfAttribute(attributePath) {
        return request_expression_builder_1.addCondition('ConditionExpression', attributePath, this, this.metadata);
    }
    /**
     * @param conditionDefFns
     * @example writeRequest.onlyIf( attribute('age').eq(23) )
     * @example writeRequest.onlyIf( or( attribute('age').lt(18), attribute('age').gt(65) ) )
     */
    onlyIf(...conditionDefFns) {
        const condition = logical_operator_1.and(...conditionDefFns)(undefined, this.metadata);
        param_util_1.addExpression('ConditionExpression', condition, this.params);
        return this;
    }
    /*
     * The ReturnValues parameter is used by several DynamoDB operations; however,
     * DeleteItem/PutItem/UpdateItem does not recognize any values other than NONE or ALL_OLD.
     */
    returnValues(returnValues) {
        this.params.ReturnValues = returnValues;
        return this;
    }
    exec() {
        return this.execFullResponse().pipe(operators_1.map(response => {
            return;
        }));
    }
}
exports.WriteRequest = WriteRequest;
//# sourceMappingURL=write.request.js.map