Skip to content

Instantly share code, notes, and snippets.

@goosmurf
Created May 22, 2009 02:58
Show Gist options
  • Save goosmurf/115892 to your computer and use it in GitHub Desktop.
Save goosmurf/115892 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'pp'
require 'rubygems'
require 'mongo'
db = XGen::Mongo::Driver::Mongo.new("localhost").db("test")
original = db.collection("original")
original.remove
original.insert( { "test" => 1 } )
copied = db.collection("copied")
copied.remove
db.eval(
'for(var c = db.original.find(); c.hasNext();) { db.copied.save(c.next()); }'
)
pp original.find_first
pp copied.find_first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment