Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Passing complex key in ruby client (2.0 Preview 3)

No replies
  • Login or register to post comments
Thu, 01/12/2012 - 11:43
devonlazarus
Offline
Joined: 12/11/2011
Groups: None

I think this is more of a Ruby question than Couchbase 2.0 but I am having trouble passing a complex key to a view.

What I want to see is:

http://127.0.0.1:8092/default/_design/message/_view/summary_by_sender?group_level=2&startkey=[%221111111111%22]&endkey=[%221111111111%22,{}]

I have been unable to produce this. The closest I have been able to get is:

startkey=%22%5B%5C%221111111111%5C%22%5D%22&endkey=%22%5B%5C%221111111111%5C%22%2C+%7B%7D%5D%22

which, of course is:

startkey="[\"1111111111\"]"&endkey="[\"1111111111\", {}]"

Obviously the quotes around the complex key aren't helping, neither are the escaped quotes around the sender.

I would think this is the proper way to pass the JSON along:

def self.summary_by_sender(sender)
  results = design.summary_by_sender(:group_level => 2, :startkey => [sender].as_json, :endkey => [sender,{}].as_json).fetch
  results.map { |result| new({:key => result['key'], :value => result['value']}) }
end

Help? I've pretty much googled everywhere and haven't found a proper Ruby example of passing a JSON array to startkey/endkey.

Top
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker