Skip to content

Instantly share code, notes, and snippets.

@joewilliams
Created May 6, 2009 22:25
Show Gist options
  • Save joewilliams/107787 to your computer and use it in GitHub Desktop.
Save joewilliams/107787 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rest_client'
url = "http://user:password@domain:5984/"
database = "database_name"
count = 100
testdocprefix = "doc"
inital_value = "test123"
updated_value = "asdf"
field_name = "test"
for i in (1..count)
RestClient.put("#{url}/#{database}/#{testdocprefix}#{i}",
"{ \"_id\": \"#{testdocprefix}#{i}\", \"#{field_name}\": \"#{inital_value}\"}",
:content_type => "application/json")
puts "creating #{testdocprefix}#{i}"
end
for i in (1..count)
RestClient.post("#{url}/#{database}/",
"{ \"_id\": \"#{testdocprefix}#{i}\", \"#{field_name}\": \"#{updated_value}\"}",
:content_type => "application/json")
puts "updating #{testdocprefix}#{i}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment