Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (25 sloc) 1.041 kB
require 'riak'
require 'lib/utils'
# Connect and get a bucket instance
client =
bucket = client.bucket("test2")
# Ensure bucket is empty. When bugfixed, pass block direct to bucket
bucket.keys.each {|k| bucket.get(k).delete}
# Create and save a simple JSON object
new_one =, "item1")
new_one.content_type = "application/json" # You must set the content type. = "{'item': 'one'}"
# Create and save a second JSON object, linking to the first
new_two =, "item2")
new_two.content_type = "application/json" # You must set the content type. = "{'item': 'two'}"
# Linking. Must be a better way to create the URL?. Link is tagged parent
new_two.links << new_one.to_link("parent")
p "** Walk the Parent Link **"
p new_two.walk(:tag => 'parent')
keys = bucket.keys(:reload => true)
puts "*** All items in bucket ***"
bucket.keys.each {|k| i = bucket.get(k) ; p i ; p i.links}
#bucket.keys.each {|k| bucket.get(k).delete}
Jump to Line
Something went wrong with that request. Please try again.