Skip to content
MongoDB DataMapper Adapter
Ruby
Find file
Pull request Compare This branch is even with solnic:nested_embeds.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin
lib
script
spec
.gitignore
LICENSE
README.rdoc
Rakefile
TODO
VERSION.yml
dm-mongo-adapter.gemspec

README.rdoc

DataMapper Mongo Adapter

WARNING

This adapter is a work-in-progress, so stay tuned :)

TODO

Embedded Objects

I have no idea. I'd guess a DM::Relationship#has hack or custom DM::Types that behave like a table-less resource?

Associations

The documentation for Mongo is confusing so I'm not sure if DBRef's are deprecated or not.

Query Performance

At the moment a single Javascript $where clause is built. Your indexes probably won't be used. A mixture of Hash conditions plus a Javascript $where clause when required would be much better.

Dependencies

Ruby

  • dm-core ~> 0.10.2

  • mongo ~> 0.18

Install

  • Via git:

    git clone git://github.com/solnic/dm-mongo-adapter.git
    rake install
  • With Rails:

    Add this to your config/environment.rb file:

    config.gem “mongo” config.gem “dm-core” config.gem “dm-mongo-adapter”, :lib => “mongo_adapter” config.gem “rails_datamapper”

Synopsis

DataMapper.setup(:default,
  :adapter  => 'mongo',
  :database => 'my_mongo_db',
)

# Define your DataMapper resource and start saving:
class User
  include DataMapper::Resource
  property :_id, ObjectID, :key => true
  property :name, String
  property :age, Integer
end

# No need to (auto_)migrate!
User.create(:name => 'Fred', :age => '25')

# Conditions:
users = User.all(:age.gte => 10, :limit => 20, :order => [:age.asc])

Contributing

Go nuts. Just send me a pull request (github or otherwise) when you are happy with your code.

Copyright

Copyright © 2009 “Shane Hanna”. See LICENSE for details.

Something went wrong with that request. Please try again.