diff --git a/lib/couchbase-orm/proxies/collection_proxy.rb b/lib/couchbase-orm/proxies/collection_proxy.rb index 9ddf54c6..0d1c94bc 100644 --- a/lib/couchbase-orm/proxies/collection_proxy.rb +++ b/lib/couchbase-orm/proxies/collection_proxy.rb @@ -35,6 +35,22 @@ def remove(id, **options) nil end + def remove_multi!(ids, **options) + result = @proxyfied.remove_multi(ids, Couchbase::Options::RemoveMulti.new(**options)) + first_result_with_error = result.find(&:error) + if first_result_with_error + raise CouchbaseOrm::Error::DocumentNotFound + end + result + end + + def remove_multi(ids, **options) + result = @proxyfied.remove_multi(ids, Couchbase::Options::RemoveMulti.new(**options)) + result.reject(&:error) + end + + + def initialize(proxyfied) raise "Must proxy a non nil object" if proxyfied.nil? @proxyfied = proxyfied diff --git a/lib/couchbase-orm/relation.rb b/lib/couchbase-orm/relation.rb index 8a92ece7..19d72890 100644 --- a/lib/couchbase-orm/relation.rb +++ b/lib/couchbase-orm/relation.rb @@ -103,7 +103,7 @@ def [](*args) def delete_all CouchbaseOrm::logger.debug{ "Delete all: #{self}" } ids = query.to_a - CouchbaseOrm::Connection.bucket.default_collection.remove_multi(ids) unless ids.empty? + @model.collection.remove_multi(ids) unless ids.empty? end def where(string_cond=nil, **conds)