Sha256: 392cbf848c53fce84c525751dd0b8d648a7ce9f573436804dc6ada28bc78a17c

Contents?: true

Size: 995 Bytes

Versions: 7

Compression:

Stored size: 995 Bytes

Contents

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

require 'mongomapper'
require 'irb'

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

IRB.conf[:MAIN_CONTEXT] = irb.context

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

MongoMapper.database = "mmtest"
$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_object.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

7 entries across 7 versions & 2 rubygems

Version Path
djsun-mongomapper-0.3.5.1 bin/mmconsole
djsun-mongomapper-0.3.5.2 bin/mmconsole
djsun-mongomapper-0.3.5.4 bin/mmconsole
djsun-mongomapper-0.3.5.5 bin/mmconsole
djsun-mongomapper-0.3.5 bin/mmconsole
jnunemaker-mongomapper-0.3.5 bin/mmconsole
djsun-mongomapper-0.4.1.2 bin/mmconsole