Sha256: 3b25e438c96acd751d0fd4e70cf9a20322f9d3693311b94ac1c7728d7a4e1035
Contents?: true
Size: 756 Bytes
Versions: 4
Compression:
Stored size: 756 Bytes
Contents
#!/usr/bin/env ruby require 'rubygems' require 'mongo' connection = Mongo::Connection.new( 'localhost', 27017 ) db_name = "fernand_mdb" cltn_names = %w[blee bobo] db = connection.db( db_name ) cltn_names.each do |cltn_name| cltn = db.create_collection( cltn_name ) cltn.remove 20.times do |i| row = { :name => "#{cltn_name}_#{i}", :last_name => "#{db_name}.#{cltn_name}_#{i}", :array => 10.times.to_a, :hash => { :blee => 5.times.to_a, :duh => "Hello", :hash => { :duh => 10 } } } puts "Inserting row #{row.inspect}" cltn.insert( row ) end cltn = db[cltn_name] puts "" puts "Inserted `#{cltn.count} records in `#{cltn_name}" end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mongo3-0.1.3 | data/populate |
mongo3-0.1.2 | data/populate |
mongo3-0.1.1 | data/populate |
mongo3-0.1.0 | data/populate |