0.0
No commit activity in last 3 years
No release in over 3 years
Simple MongoDB Object Wrapper based on Hashie
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0
>= 0

Runtime

 Project Readme

mongo-hashie¶ ↑

mongo-hashie is a mongodb library that aims to be simple and effective. No need to explicitly define properties. Getters and setters are created through the underlying Mash class from hashie.

Install¶ ↑

$ gem install mongo-hashie

Usage¶ ↑

$ class Document < MongoHashie::Base
$ end

Simply add new properties by calling the setter.

Basic CRUD operations

$ document = Document.new(:author => "Oliver Kiessler")
$ document.name = "test attribute"
$ document.save # create
$ puts document._id # Mongo ObjectID String represenation

$ document.name = "simple change"
$ document.save # update

$ document.destroy

$ document2 = Document.create(:author => "Oliver Kiessler", :name => "Great Document Name")

$ Document.destroy_all

Find operations

$ Document.first
$ Document.find("4b3f4bd4c1d7110513000001") # Mongo ObjectID String represenation

$ Document.all
$ Document.all(:author => "Oliver Kiessler")
$ Document.find(:author => "Oliver Kiessler", :name => "Great Document Name")

$ Document.count

Meta Data

$ document1 = Document.create(:author => "Oliver Kiessler", :name => "Great Document Name", :prop1 => "Test")
$ document2 = Document.create(:author => "Oliver Kiessler", :name => "Great Document Name", :prop2 => "Test")
$ document3 = Document.create(:author => "Oliver Kiessler", :name => "Great Document Name", :prop3 => "Test")

$ puts Document.properties_used.inspect

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 I can ignore when I pull)

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

Copyright © 2009/2010 Oliver Kiessler. See LICENSE for details.