0.0
No commit activity in last 3 years
No release in over 3 years
Provide a syntatic sugar for MongoDB ruby driver, similar to an ORM.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.1
>= 1.1
 Project Readme

Mongo Sugar Build Status

Provide a syntatic sugar for official MongoDB ruby driver, similar to an ORM.

But it isn't another ORM. If you need relationship features, you should use MongoID, MongoMapper, or, why not - a relational database.

Usage

Add mongo-sugar to your gemfile:

gem 'mongo-sugar'

Require it on your code:

require 'mongo-sugar'

Define classes as collections. By default, collection names are the class name underscored. On the following example, the collection name is my_collection.

class MyCollection < Mongo::Sugar::Collection
  #
  # Define your custom methods, like this:
  #
  def do_upsert(hash)
    @collection.update({
      key: hash[:key]
    }, {
      :$addToSet => {
        :value => hash[:value]
      }
    }, :upsert => true)
  end
end

You can customize the collection names using store_in, which is similar to mongoid syntax.

class MyCollection < Mongo::Sugar::Collection
  store_in :collection => 'custom_collection'
end

For more details, read the documentation here.

License

This library is released under MIT License. Please see LICENSE file.