public async Task <(ulong updatedCas, MutationToken mutationToken)> MutateStagedRemove(TransactionGetResult doc, IAtrRepository atr) { // For ExtAllKvCombinations, the Java implementation was updated to write "txn" as one JSON blob instead of multiple MutateInSpecs. // Remove is the one where it had to be updated, given that we need to remove the staged data only if it exists. var txn = new TransactionXattrs() { Operation = new StagedOperation() { Type = "remove" }, Id = new CompositeId() { Transactionid = _overallContext.TransactionId, AttemptId = _attemptId }, AtrRef = new AtrRef() { Id = atr.AtrId, ScopeName = atr.ScopeName, BucketName = atr.BucketName, CollectionName = atr.CollectionName }, RestoreMetadata = doc.DocumentMetadata }; var txnAsJObject = Newtonsoft.Json.Linq.JObject.FromObject(txn, _metadataSerializer); var specs = new MutateInSpec[] { MutateInSpec.Upsert(TransactionFields.TransactionInterfacePrefixOnly, txnAsJObject, isXattr: true), MutateInSpec.Upsert(TransactionFields.Crc32, MutationMacro.ValueCRC32c, createPath: true, isXattr: true), }; var opts = GetMutateInOptions(StoreSemantics.Replace).Cas(doc.Cas).CreateAsDeleted(true); var updatedDoc = await doc.Collection.MutateInAsync(doc.Id, specs, opts).CAF(); return(updatedDoc.Cas, updatedDoc.MutationToken); }
internal static TransactionGetResult FromInsert( ICouchbaseCollection collection, string id, IContentAsWrapper content, string transactionId, string attemptId, string atrId, string atrBucketName, string atrScopeName, string atrCollectionName, ulong updatedCas, bool isDeleted ) { var txn = new TransactionXattrs(); txn.AtrRef = new AtrRef() { BucketName = atrBucketName, CollectionName = atrCollectionName, ScopeName = atrScopeName, Id = atrId }; txn.Id = new CompositeId() { Transactionid = transactionId, AttemptId = attemptId }; return(new TransactionGetResult( id, content, updatedCas, collection, txn, null, isDeleted )); }