Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement remove_multi #87

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading