def delete(doc)

      drev = doc['_rev']

      raise ArgumentError.new('cannot delete doc without _rev') unless drev

      type, key = doc['type'], doc['_id']

      r =
        lock(:delete, type, key) do |f|

          cur = do_get(f)

          return nil unless cur
          return cur if cur['_rev'] != drev

          begin
            f.close
            File.delete(f.path)
            nil
          rescue Exception => e
            #p e
            false
          end
        end

      r == false ? true : nil
    end
def delete(doc)

      drev = doc['_rev']

      raise ArgumentError.new('cannot delete doc without _rev') unless drev

      type, key = doc['type'], doc['_id']

      r =
        lock(:delete, type, key) do |f|

          cur = do_get(f)

          return nil unless cur
          return cur if cur['_rev'] != drev

          begin
            f.close
            File.delete(f.path)
            nil
          rescue Exception => e
            #p e
            false
          end
        end

      r == false ? true : nil
    end
Attempts at deleting a document. You have to pass the current version
 or at least the { '_id' => i, 'type' => t, '_rev' => r }.

 Will return nil if the deletion is successful.

 If the deletion failed because the given doc has an older revision number
 that the one currently stored, the doc in its freshest version will be
 returned.

 Returns true if the deletion failed.