Skip to content

Commit

Permalink
Merge pull request #87 from Mapotempo/add_remove_multi_proxy
Browse files Browse the repository at this point in the history
implement remove_multi
  • Loading branch information
giallon authored May 31, 2024
2 parents ec1c28f + 7313040 commit 262eab7
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 262eab7

Please sign in to comment.