lib/ruote/couch/database.rb in ruote-couch-2.1.1 vs lib/ruote/couch/database.rb in ruote-couch-2.1.4
- old
+ new
@@ -55,21 +55,11 @@
@couch.get(key)
end
def delete (doc)
- begin
-
- @couch.delete(doc)
-
- rescue Rufus::Jig::HttpError => he
- if he.status == 404
- true
- else
- raise he
- end
- end
+ @couch.delete(doc)
end
def get_many (key, opts)
os = if l = opts[:limit]
@@ -86,10 +76,19 @@
# naive...
rs
end
+ # Returns a sorted list of the ids of all the docs in this database.
+ #
+ def ids
+
+ rs = @couch.get('_all_docs')
+
+ rs['rows'].collect { |r| r['id'] }
+ end
+
def dump
s = "=== #{@type} ===\n"
get_many(nil, {}).inject(s) do |s1, e|
@@ -103,13 +102,23 @@
def shutdown
@couch.close
end
+ # Deletes database and closes it.
+ #
def purge!
@couch.delete('.')
@couch.close
+ end
+
+ # Removes all the documents in this database.
+ #
+ def purge_docs!
+
+ @couch.delete('.')
+ @couch.put('.')
end
protected
def prepare