lib/picky/sources/couch.rb in picky-1.1.2 vs lib/picky/sources/couch.rb in picky-1.1.3

- old
+ new

@@ -7,10 +7,25 @@ # class NoCouchDBGiven < StandardError; end # A Couch database source. # + # <b>IMPORTANT NOTE: + # + # Since Picky currently only handles integer ids (we're working on this), + # and CouchDB uses hexadecimal ids, this source automatically + # recalculates a couch id such as + # fa3f2577a8dbc6a91d7f9989cdffd38e + # into + # 332634873577882511228481564366832915342 + # using String#hex. + # + # When using the integer ids in a webapp to get your + # objects from CouchDB, please do a Integer#to_s(16) on the + # ids you get from Picky before you use them to get your object from CouchDB.</b> + # + # # Options: # * url # and all the options of a <tt>RestClient::Resource</tt>. # See http://github.com/archiloque/rest-client. # @@ -35,13 +50,15 @@ exit 1 end # Harvests the data to index. # + # See important note, above. + # def harvest type, category category_name = category.from.to_s get_data do |doc| - yield doc['_id'].to_i, doc[category_name] || next + yield doc['_id'].hex, doc[category_name] || next end end def get_data &block # :nodoc: resp = @db['_all_docs?include_docs=true'].get