Sha256: 5fdd2dbe6e3ffba87989dd6aaee9a48048bda309fcf24ecd2271be2ef7d0259a

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

module Nazrin
  class DataAccessor
    class Mongoid < Nazrin::DataAccessor
      def load_all(ids)
        documents_table = {}
        options.each do |k, v|
          @model = if v.nil?
                     model.send(k)
                   else
                     model.send(k, v)
                   end
        end
        model.where('_id' => { '$in' => ids }).each do |document|
          documents_table[document._id.to_s] = document
        end
        ids.map do |id|
          documents_table[id]
        end.reject(&:nil?)
      end

      def data_from_response(res)
        res.data.hits.hit.map(&:id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nazrin-2.6.2 lib/nazrin/data_accessor/mongoid.rb