Sha256: 49620498de0983cc5bc92f667f1a56a8542b9975117fcebdf1b35116ff825ead

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

# encoding: utf-8
require 'bson_ext'
require 'mongo'
module MongodbHelpers
  def collectioncount(dbcollections)
    @remote_mongodb = Mongo::MongoClient.new(
      'localhost' || $redis.hget('config', 'remotemongo:host'),
      27017 || $redis.hget('config', 'remotemongo:port'),
    )
    result = Hash.new
    dbcollections.keys.each do |db|
      @db = @remote_mongodb[db]
      count = Hash.new
      dbcollections[db].each do |collection|
        count.merge!(collection => @db[collection].stats['count'])
      end
      result.merge!(db => count)
    end
    return result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gaptool-server-0.2.4 lib/helpers/mongodb.rb