solnic / dm-mongo-adapter forked from shanna/dm-mongo-adapter

Mongo DataMapper Adapter

This URL has Read+Write access

solnic (author)
Sun Nov 01 14:42:27 -0800 2009
commit  278511861aa810047caeac50dc19eb4bc33a0f72
tree    146b9e14acc2cc04d9c042cc2a42b320ebcff9b2
parent  b5402eae5b54d3365c9d9e5f65d302bd07ed8c2f
name age message
file .gitignore Sun Jun 21 18:41:41 -0700 2009 Initial commit to dm-mongo-adapter. [shanna]
file LICENSE Sun Jun 21 18:41:41 -0700 2009 Initial commit to dm-mongo-adapter. [shanna]
file README.rdoc Mon Jun 29 01:10:13 -0700 2009 Updated documentation now I have an ObjectID type. [shanna]
file Rakefile Thu Jun 25 07:29:32 -0700 2009 Gem is only on github. [shanna]
file VERSION.yml Tue Jun 23 21:45:14 -0700 2009 Version bump to 0.1.0 [shanna]
file dm-mongo-adapter.gemspec Thu Jun 25 07:29:57 -0700 2009 Regenerated gemspec for version 0.1.0 [shanna]
directory lib/ Loading commit data...
directory spec/
README.rdoc

DataMapper Mongo Adapter

WARNING

This adapter is shit, I’m just trying to make a start. Steal what you can or write something better :)

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.0
  • mongo ~> 0.8

Install

  • Via git:
      git clone git://github.com/shanna/dm-mongo-adapter.git
      rake install
    

Synopsis

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

  # Define your DataMapper resource and start saving:
  class User
    include DataMapper::Resource
    property :id, DataMapper::Mongo::Types::ObjectID, :field => '_id', :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.