Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

85 lines (48 sloc) 2.52 kb

Sequence plugin

This will enable one to use SQL-like sequence for id (_id).

Just do

include MongoMapper::Document
include UseSequenceAsMongoId

Strict Keys

When you do

Foo.create(:explicit_key => 'bar', :implicity_key => 'cake')

even when :implicity_key was not definied (i.e. key :implicity_key, String), MongoMapper will still create the new key and insert the document.

If you want to disable that for mantainability, do

include SaveToMongoKeysOnly
include MongoMapper::Document

Embedded documents without id (_id)

Sometimes there's no reason to use id for embedded documents. Just do

include NoEmbeddedMongoId
include MongoMapper::EmbeddedDocument

Operator 'e'

When you do

Foo.all(:array => [1,2])

what you get is actually

Foo.all(:array.in => [1,2])

which is fine in most case, but sometimes you just want to match the exact array (as in spatial data). Now you can do

Foo.all(:array.e => [1,2])

which guarantees no operator will be used.

Disclaimer for the new features

All the old tests pass. But I still need to write tests for the new features.

How to use spatial index

key :lat_lng, Array # or use embedded document type
ensure_index [[:lat_lng, "2d"]]

MongoMapper

A Ruby Object Mapper for Mongo.

Releases are tagged on github and released on gemcutter. Master is pushed to whenever I add a patch or a new feature, but I do not release a new gem version each time I push.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Install

$ gem install mongo_mapper

Problems or Questions?

Hit up the google group. groups.google.com/group/mongomapper

To see if the problem you are having is a verified issue, you can see the MM pivotal tracker project: www.pivotaltracker.com/projects/33576

There is no need to request to join the Pivotal Tracker project as I am only granting access to a select few (easier to keep things organized). If you have a problem, please use the mailing list. If I confirm it to be a bug, I am happy to add it to PT. Thanks!

Copyright

Copyright © 2009 John Nunemaker. See LICENSE for details.

Jump to Line
Something went wrong with that request. Please try again.