public async Task Remove(IBucket bucket, ITransactionDocument document)
        {
            await UpdateAtr(bucket, document.Key).ConfigureAwait(false);

            var result = await bucket.MutateIn <dynamic>(document.Key)
                         .Upsert(AtrIdFieldName, AtrId, SubdocPathFlags.Xattr)
                         .Upsert(AtrBucketNameFieldName, AtrBucket.Name, SubdocPathFlags.Xattr)
                         .Upsert(StagedVersionFieldName, AttemptId, SubdocPathFlags.Xattr)
                         .Upsert(StagedDataFieldName, RemovedStagedData, SubdocPathFlags.Xattr)
                         .WithCas(document.Cas)
                         .WithDurability(_config.PersistTo, _config.ReplicateTo)
                         .WithTimeout(_config.KeyValueTimeout)
                         .ExecuteAsync()
                         .ConfigureAwait(false);

            if (!result.Success)
            {
                //TODO: failed to remove
                return;
            }

            // update transaction document CAS and add to staged removes
            document.Cas = result.Cas;
            _stagedRemoves[document.Key] = document;
        }
        private bool TryGetStagedWrite(string key, out ITransactionDocument document)
        {
            if (_stagedInserts.TryGetValue(key, out var item))
            {
                document = item;
                return(true);
            }

            if (_stagedReplaces.TryGetValue(key, out item))
            {
                document = item;
                return(true);
            }

            document = default(TransactionDocument <object>);
            return(false);
        }