Sha256: 1a47b25d7b92534380fe64c426e73fd3a3a4f0e1fd035e11b8e4f1d089ab5c55

Contents?: true

Size: 627 Bytes

Versions: 11

Compression:

Stored size: 627 Bytes

Contents

require 'rubygems'
require 'couchrest'

# set the source db and map view
source = CouchRest.new("http://localhost:5984").database('source-db')
source_view = 'mydesign/view-map'

# set the target db
target = CouchRest.new("http://localhost:5984").database('target-db')


pager = CouchRest::Pager.new(source)

# pager will yield once per uniq key in the source view

pager.key_reduce(source_view, 10000) do |key, values|
  # create a doc from the key and the values
  example_doc = {
    :key => key,
    :values => values.uniq
  }

  target.save(example_doc)
  
  # keep us up to date with progress
  puts k if (rand > 0.9)
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
jchris-couchrest-0.9.10 utils/remap.rb
jchris-couchrest-0.9.11 utils/remap.rb
jchris-couchrest-0.9.12 utils/remap.rb
jchris-couchrest-0.9.4 utils/remap.rb
jchris-couchrest-0.9.5 utils/remap.rb
jchris-couchrest-0.9.6 utils/remap.rb
jchris-couchrest-0.9.7 utils/remap.rb
jchris-couchrest-0.9.8 utils/remap.rb
jchris-couchrest-0.9.9 utils/remap.rb
juozasg-couchrest-0.10.1 utils/remap.rb
topfunky-couchrest-0.9.4 utils/remap.rb