Skip to content

Instantly share code, notes, and snippets.

@banker
Created October 22, 2009 17:52
Show Gist options
  • Save banker/216132 to your computer and use it in GitHub Desktop.
Save banker/216132 to your computer and use it in GitHub Desktop.
Using mongo-0.15.1 with mongo_ext-0.15.1
require 'rubygems'
require 'mongo'
db = Mongo::Connection.new('localhost', 27017).db('stuff')
coll = db['stuff']
coll.remove
coll.save({"_id" => "4ae06a7662125b1b72000001", 'name' => "first doc"})
coll.save({'_id' => '4ae06a7662125b1dsf000002', 'name' => "second doc"})
coll.save({'name' => "doc without id"})
------
Results:
> db.stuff.find()
{ "_id" : "4ae06a7662125b1b72000001", "name" : "first doc" }
{ "_id" : "4ae06a7662125b1dsf000002", "name" : "second doc" }
{ "_id" : ObjectId("4ae09bae62125b2410000001"), "name" : "doc without id" }
Same behavior without mongo_ext.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment