Skip to content

Commit

Permalink
implement remove_multi
Browse files Browse the repository at this point in the history
(cherry picked from commit 5a6f487)
  • Loading branch information
Giallombardo Nathan authored and Giallombardo Nathan committed May 31, 2024
1 parent ec1c28f commit 7313040
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/couchbase-orm/proxies/collection_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/couchbase-orm/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7313040

Please sign in to comment.