A MongoDB engine for Arel
MIT License
= arel-mongo
An experimental MongoDB engine for Arel.
== A Quick Tour
Arel::Collection is comparable to Arel::Table. Collections may be initialized with attributes for typecasting:
users = Collection.new(:users, :attributes => [[:name, Attributes::String, :profile, Attributes::Hash]])
users.insert([{ :name => 'bob', :profile => { :location => 'Earth', :rating => 1 } }])
The standard Arel predicates and operators work as expected.
users.where(users[:name].eq('bob'))
But this would all be pointless without support for embedded documents,
users.where(users['profile.location'].eq('Earth')) users.where(users[:profile].elem(users['profile.rating'].gte(1), users['profile.location'].eq('Earth')))
and Mongo-specific predicates:
users.where(users[:name].exists(true))
Arel Mongo also supports MongoDB cursors with efficient caching thanks to Hamster.
What about atomic updates?
users.where(users[:name].eq('bob')).update(users['profile.rating'].incr(1))
Sweet!
== Status
This is a conversation-starter for now.
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 akdubya. See LICENSE for details.