document view queries

This commit is contained in:
Chris Anderson 2008-10-03 14:23:31 -07:00
parent ba16fb586a
commit 75bbb26c7a

View file

@ -49,6 +49,25 @@ module CouchRest
# self['slug'] = title.downcase.gsub(/[^a-z0-9]/,'-').squeeze('-').gsub(/^\-|\-$/,'')
# end
# end
#
# ==== Examples of finding articles with these views:
#
# * All the articles by Barney published in the last 24 hours. Note that we
# use <tt>{}</tt> as a special value that sorts after all strings,
# numbers, and arrays.
#
# Article.by_user_id_and_date :startkey => ["barney", Time.now - 24 * 3600], :endkey => ["barney", {}]
#
# * The most recent 20 articles. Remember that the <tt>view_by :date</tt>
# has the default option <tt>:descending => true</tt>.
#
# Article.by_date :count => 20
#
# * The raw CouchDB view reduce result for the custom <tt>:tags</tt> view.
# In this case we'll get a count of the number of articles tagged "ruby".
#
# Article.by_tags :key => "ruby", :reduce => true
#
class Model < Hash
# instantiates the hash by converting all the keys to strings.