Module: MongoUtils::MongoDump

Defined in:
lib/mongo_utils/mongo_dump.rb

Class Method Summary collapse

Class Method Details

.call(options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/mongo_utils/mongo_dump.rb', line 3

def self.call(options)
  cmd = %{
    mongodump --db         #{Mongoid.respond_to?(:database) ? Mongoid.database.name : Mongoid.default_session['database'].database.name}
              --host       #{Mongoid.respond_to?(:database) ? Mongoid.database.connection.primary.join(':') : Mongoid.sessions['default']['hosts'][0]}
              --collection #{options[:collection]}
              --query      "#{options[:query]}"
              -o           #{options[:path]}
  }.squish
  `#{cmd}`      
end