Sha256: 4214d2f1e9675cd941776768cbf393456bd5ca17b311a33245ef95dc851f52f4

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 Bytes

Contents

# MongoidFindBy [![Build Status](https://secure.travis-ci.org/Langwhich/mongoid_find_by.png)](https://secure.travis-ci.org/Langwhich/mongoid_find_by)

MongoidFindBy adds simple functions to mongoid documents to find documents
by dynamic fields.

## Install

 ```ruby
 gem 'mongoid_find_by'
 ```

## Usage

 ```ruby
 class Person
   include Mongoid::Document
   include Mongoid::FindBy

   field :name, :type => String
 end
 ```

 ```ruby
 # returns a single document
 Person.find_by_name('Thomas')
 Person.find_first_by_name('Thomas')
 Person.find_last_by_name('Thomas')
 
 # returns a document collection
 Person.find_all_by_name('Thomas')

 # throws Mongoid::Errors::DocumentNotFound
 # exception for non existent documents
 Person.find_by_name!('Thomas)
 ```

## Credits

Copyright (c) 2012 Langwhich GmbH <http://www.langwhich.com>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid_find_by-0.1.1 README.md
mongoid_find_by-0.1.0 README.md