Skip to content

Instantly share code, notes, and snippets.

@scalabilitysolved
Created February 23, 2014 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scalabilitysolved/9174714 to your computer and use it in GitHub Desktop.
Save scalabilitysolved/9174714 to your computer and use it in GitHub Desktop.
require 'json'
require 'couchbase'
@couchbase = Couchbase.connect(:bucket => "users",:hostname => "localhost")
def retreive_offer_data
design_doc = @couchbase.design_docs["users"]
offers_collected = {}
offers_collected['date'] = Time.now.utc.to_s
offers_collected['doc_type'] = 'offers_collected'
design_doc.by_offers(:group => true,:group_level => 1).each do |row|
offers_collected[row.key.to_s.gsub("\"","")] = row.value
end
offers_collected
end
id = @couchbase.incr("offers_collected",:create => true)
@couchbase.set('offers_collected' + id.to_s,retreive_offer_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment