Sha256: af0902e336061c4a0017b2c43d18d95e903f5f25cf80b955b2d06249e290fc2b

Contents?: true

Size: 627 Bytes

Versions: 163

Compression:

Stored size: 627 Bytes

Contents

require 'rubygems'
require 'couchrest'

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

# set the target db
target = CouchRest.new("http://127.0.0.1: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

163 entries across 163 versions & 31 rubygems

Version Path
couchrest-2.0.1 utils/remap.rb
couchrest-2.0.0 utils/remap.rb
couchrest-2.0.0.rc3 utils/remap.rb
couchrest-2.0.0.rc2 utils/remap.rb
couchrest-2.0.0.rc1 utils/remap.rb
couchrest-2.0.0.beta2 utils/remap.rb
couchrest-2.0.0.beta1 utils/remap.rb
couchrest-1.2.1 utils/remap.rb
dpla-couchrest-1.2.1.pre.dpla utils/remap.rb
brianmario-couchrest-0.23 utils/remap.rb
derfred-couchrest-0.12.6.3 utils/remap.rb
derfred-couchrest-0.12.6 utils/remap.rb
gbuesing-couchrest-0.23 utils/remap.rb
glasner-couchrest-0.2.2 utils/remap.rb
gohanlonllc-couchrest-0.2.3.1 utils/remap.rb
halfninja-couchrest-0.23.2 utils/remap.rb
halfninja-couchrest-0.23.3 utils/remap.rb
jchris-couchrest-0.12.2 utils/remap.rb
jchris-couchrest-0.12.4 utils/remap.rb
jchris-couchrest-0.12.5 utils/remap.rb