Sha256: 82cf1e2b3307e58acacbdec4d950e3c2fe640327c6527729cb5126cf3949f459

Contents?: true

Size: 532 Bytes

Versions: 4

Compression:

Stored size: 532 Bytes

Contents

module DataMapper
  module Mongo
    module Aggregates
      # TODO: document
      # @api semipublic
      def aggregate(query)
        operator = if query.fields.size == 1 && query.fields.first.target == :all
          :count
        else
          :group
        end

        with_collection(query.model) do |collection|
          Query.new(collection, query).send(operator)
        end
      end
    end # class Aggregates
  end # module Mongo

  Aggregates::MongoAdapter = DataMapper::Mongo::Aggregates
end # module DataMapper

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dm-mongo-adapter-0.6.0 lib/mongo_adapter/aggregates.rb
dm-mongo-adapter-0.2.0.pre3 lib/mongo_adapter/aggregates.rb
dm-mongo-adapter-0.2.0.pre2 lib/mongo_adapter/aggregates.rb
dm-mongo-adapter-0.2.0.pre1 lib/mongo_adapter/aggregates.rb