Sha256: 1473ed3f15fc3aa4dc9c3fce5558c3762eafd7a9cc81035cb0ea9e8135310162

Contents?: true

Size: 1.01 KB

Versions: 15

Compression:

Stored size: 1.01 KB

Contents

#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + '/../lib')

begin
  require 'mongo_mapper'
  require 'irb'
rescue LoadError
  require 'rubygems'
  retry
end

IRB.setup(nil)
irb = IRB::Irb.new

IRB.conf[:MAIN_CONTEXT] = irb.context

irb.context.evaluate("require 'irb/completion'", 0)
irb.context.evaluate(%@

MongoMapper.database = "mm-test"
$db = MongoMapper.database

@, 0)

puts %@
Welcome to the MongoMapper Console!

Example 1:
  things = $db.collection("things")
  things.insert("name" => "Raw Thing")
  things.insert("name" => "Another Thing", "date" => Time.now)

  cursor = things.find("name" => "Raw Thing")
  puts cursor.next.inspect

Example 2:
  class Thing
    include MongoMapper::Document
    key :name, String, :required => true
    key :date, Time
  end

  thing = Thing.new
  thing.name = "My thing"
  thing.date = Time.now
  thing.save

  all_things = Thing.all
  puts all_things.map { |object| object.name }.inspect
@

trap("SIGINT") do
  irb.signal_handle
end

catch(:IRB_EXIT) do
  irb.eval_input
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mongo_mapper-0.17.0 bin/mmconsole
mongo_mapper-0.16.0 bin/mmconsole
mongo_mapper-0.15.6 bin/mmconsole
mongo_mapper-0.15.5 bin/mmconsole
mongo_mapper-0.15.4 bin/mmconsole
mongo_mapper-0.15.3 bin/mmconsole
mongo_mapper-0.15.2 bin/mmconsole
mongo_mapper-0.15.1 bin/mmconsole
mongo_mapper-0.15.0 bin/mmconsole
mongo_mapper-0.14.0 bin/mmconsole
mongo_mapper-0.14.0.rc1 bin/mmconsole
mongo_mapper-0.13.1 bin/mmconsole
mongo_mapper-0.13.0 bin/mmconsole
mongo_mapper-0.13.0.beta2 bin/mmconsole
mongo_mapper-0.13.0.beta1 bin/mmconsole