Module: CouchRest::Model::DocumentQueries::ClassMethods
- Defined in:
- lib/couchrest/model/document_queries.rb
Instance Method Summary (collapse)
-
- (Object) count
Wrapper for the master design documents all method to provide a total count of entries.
-
- (Object) first
Wrapper for the master design document's first method on all view.
-
- (Object) get(id, db = database)
(also: #find)
Load a document from the database by id No exceptions will be raised if the document isn't found.
-
- (Object) get!(id, db = database)
(also: #find!)
Load a document from the database by id An exception will be raised if the document isn't found.
-
- (Object) last
Wrapper for the master design document's last method on all view.
Instance Method Details
- (Object) count
Wrapper for the master design documents all method to provide a total count of entries.
10 11 12 |
# File 'lib/couchrest/model/document_queries.rb', line 10 def count all.count end |
- (Object) first
Wrapper for the master design document's first method on all view.
15 16 17 |
# File 'lib/couchrest/model/document_queries.rb', line 15 def first all.first end |
- (Object) get(id, db = database) Also known as: find
Load a document from the database by id No exceptions will be raised if the document isn't found
Returns
Object |
if the document was found |
or
Nil |
Parameters
|
35 36 37 38 39 40 41 |
# File 'lib/couchrest/model/document_queries.rb', line 35 def get(id, db = database) begin get!(id, db) rescue nil end end |
- (Object) get!(id, db = database) Also known as: find!
Load a document from the database by id An exception will be raised if the document isn't found
Returns
Object |
if the document was found |
or Exception
Parameters
id<String, Integer> |
Document ID |
db<Database> |
optional option to pass a custom database to use |
55 56 57 58 59 60 61 62 |
# File 'lib/couchrest/model/document_queries.rb', line 55 def get!(id, db = database) raise CouchRest::Model::DocumentNotFound if id.blank? doc = db.get id build_from_database(doc) rescue RestClient::ResourceNotFound raise CouchRest::Model::DocumentNotFound end |
- (Object) last
Wrapper for the master design document's last method on all view.
20 21 22 |
# File 'lib/couchrest/model/document_queries.rb', line 20 def last all.last end |