Beispiel #1
0
        public async Task <bool> ExecuteAsync(CancellationToken cancellationToken)
        {
            _request.ConditionExpression = _converter.ConvertConditions(_table.Options);
            try {
                await _table.DynamoClient.DeleteItemAsync(_request);

                return(true);
            } catch (ConditionalCheckFailedException) {
                return(false);
            }
        }
Beispiel #2
0
        public IDynamoTableTransactWriteItems End()
        {
            // combine update actions
            var result = new List <string>();
            var modifiedAttributeName  = _converter.GetAttributeName("_m");
            var modifiedAttributeValue = _converter.GetExpressionValueName(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());

            result.Add($"SET {string.Join(", ", _setOperations.Append($"{modifiedAttributeName} = {modifiedAttributeValue}"))}");
            if (_removeOperations.Any())
            {
                result.Add($"REMOVE {string.Join(", ", _removeOperations)}");
            }
            if (_addOperations.Any())
            {
                result.Add($"ADD {string.Join(", ", _addOperations)}");
            }
            if (_deleteOperations.Any())
            {
                result.Add($"DELETE {string.Join(", ", _deleteOperations)}");
            }

            // update request
            _update.ConditionExpression = _converter.ConvertConditions(_parent.Table.Options);
            _update.UpdateExpression    = string.Join(" ", result);
            return(_parent);
        }
Beispiel #3
0
        //--- Methods ---
        private void PrepareRequest(bool fetchAllAttributes)
        {
            // inherit the expected types from the query select construct
            foreach (var expectedType in _queryClause.TypeFilters)
            {
                _converter.AddExpectedType(expectedType);
            }

            // initialize request
            _request.IndexName = _queryClause.IndexName;
            _request.KeyConditionExpression = _queryClause.GetKeyConditionExpression(_converter);
            _request.FilterExpression       = _converter.ConvertConditions(_table.Options);
            _request.ProjectionExpression   = _converter.ConvertProjections();

            // NOTE (2021-06-23, bjorg): the following logic matches the default behavior, but makes it explicit
            // if `ProjectionExpression` is set, only return specified attributes; otherwise, for an index, return projected attributes only; for tables, return all attributes from each row
            if (_request.ProjectionExpression is null)
            {
                if ((_request.IndexName is null) || fetchAllAttributes)
                {
                    _request.Select = Select.ALL_ATTRIBUTES;
                }
                else
                {
                    _request.Select = Select.ALL_PROJECTED_ATTRIBUTES;
                }
            }
Beispiel #4
0
 public IDynamoTableTransactWriteItems End()
 {
     _put.ConditionExpression = _converter.ConvertConditions(_parent.Table.Options);
     return(_parent);
 }