Created
October 22, 2009 17:48
-
-
Save banker/216127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using MongoMapper 0.5.4 with mongo-0.15.1 and mongo_ext-0.15.1 | |
require 'rubygems' | |
require 'mongo_mapper' | |
MongoMapper.connection = Mongo::Connection.new('localhost', 27017) | |
MongoMapper.database = 'dupes' | |
class Doc | |
include MongoMapper::Document | |
key :data, String | |
end | |
Doc.delete_all | |
d = Doc.new :data => "First doc" | |
d.save | |
d = Doc.new :name => "Second doc (not using defined key)" | |
d.save | |
d = Doc.new '_id' => "1234534343433", :data => "Doc with preset id" | |
d.save | |
------- | |
Results: | |
> db.docs.find() | |
{ "_id" : "4ae09ac962125b23dc000001", "_id" : "4ae09ac962125b23dc000001", "data" : "First doc" } | |
{ "_id" : "4ae09ac962125b23dc000002", "_id" : "4ae09ac962125b23dc000002", "name" : "Second doc (not using defined key)" } | |
{ "_id" : "1234534343433", "_id" : "1234534343433", "data" : "Doc with preset id" } | |
------- | |
With mongo_ext uninstalled: | |
> db.docs.find() | |
{ "_id" : "4ae09c5062125b2432000001", "data" : "First doc" } | |
{ "_id" : "4ae09c5062125b2432000002", "name" : "Second doc (not using defined key)" } | |
{ "_id" : "1234534343433", "data" : "Doc with preset id" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment