コード例 #1
0
        public bool DeleteDocument(string key, Guid?etag, out JObject metadata)
        {
            var docPos = Mutator.Documents.FindValue(key);

            metadata = null;
            if (docPos == null)
            {
                return(false);
            }
            var existingEtag = EnsureValidEtag(docPos.Value, etag);

            Mutator.DecrementDocumentCount();
            Reader.Position = docPos.Value;
            ConsumeKeyFromFile();
            metadata = JObject.Load(new BsonReader(Reader));
            var docId = metadata.Value <int>("@docId");

            Mutator.DocumentsById.Remove(docId);
            Mutator.DocumentsByEtag.Remove(new Guid(existingEtag).ToByteArray());
            Mutator.Documents.Remove(key);
            return(true);
        }