Just pushed 0.6.0. Some major changes so listen up. :)
1. Switched to object ids by default for _id type
This is the biggest change. I was using the string representation of object ids as I didn't want to force people to convert strings to object ids when querying. Because of some changes to FinderOptions, MM is now smart enough to do this automatically for you.
The default _id type is now ObjectId which uses Mongo::ObjectID behind the scenes. If you have production data that you don't want to convert to object ids, you can just declare _id as a string and all will work as it did before.
# backwards compat example
class Foo
include MongoMapper::Document
key :_id, String
end
This change should make MM play much nicer with the other language drivers and conforms more closely to the mongo way. You can still use custom string id's as well (or any _id type for that matter).
# custom string id example
class Foo
include MongoMapper::Document
key :_id, String
end
foo = Foo.new(:id => 'awesome')
foo.using_custom_id? # true
2. find returns nil, find! raises exceptions
find now returns nil when a document is not found by id instead of raising an exception. If you want to raise DocumentNotFound, you can use find! with a bang. A few people raised the point that this is more consistent and I agree.
find(id) # returns nil if not found
find!(id) # raises exception if not found
Same goes for find with multiple ids.
3. Setting database for document
To set the database for a document you must now use set_database name instead of database. This is only if you are using a different database than the default (MongoMapper.database).
class Foo
include MongoMapper::Document
set_database_name 'foo'
end
4. Other Changes/Fixes
* added support for :class as option on association in place of string class_name which makes even more dynamic stuff possible
* moved validates inclusion and exclusion of to validatable and incremented required validatable version
* added case_sensitive option to validates_uniqueness_of. For now this drops down to $where.
* validations can be skipped when saving. save(false) just like AR
* fixed pagination with :conditions
* several ruby 1.9 fixes, still not officially supporting but the brave are welcome
* fixed mmconsole which wasn't working
* added human_name for formtastic compatibility
* added some documentation