4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/helpers/mongodb.rb', line 4
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
|