Class: Esse::AsyncIndexing::Actions::BatchDelete

Inherits:
Object
  • Object
show all
Defined in:
lib/esse/async_indexing/actions/batch_delete.rb

Class Method Summary collapse

Class Method Details

.call(index_class_name, repo_name, ids, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/esse/async_indexing/actions/batch_delete.rb', line 5

def self.call(index_class_name, repo_name, ids, options = {})
  docs = Esse::LazyDocumentHeader.coerce_each(ids)
  return if docs.empty?

  index_class, _repo_class = CoerceIndexRepository.call(index_class_name, repo_name)
  bulk_opts = Esse::HashUtils.deep_transform_keys(options, &:to_sym)
  index_class.bulk(**bulk_opts, delete: docs.map(&:to_doc))
  docs.size
end