pouchdb-community / pouchdb-load

Load documents into CouchDB/PouchDB from a dumpfile
Apache License 2.0
120 stars 33 forks source link

Error loading dump with filter view #41

Closed Coniglioz closed 8 years ago

Coniglioz commented 8 years ago

The error is: TypeError: Cannot read property 'toString' of undefined at generateReplicationId on line 2272 of pouchdb.load.js

This happens when you load the dump using a view as filter, for example:

db.load('http://example.com/my-dump-file.txt', {
  proxy: 'http://mysite.com/mydb',
  filter: '_view',
  view: 'mydesign/myview'
})

Suggested solution Complete the "replIdOpts" object passed to "genReplicationId" on line 67 by adding the "view" attribute.

...
if (opts.view) {
  replIdOpts.view = opts.view;
}
...
nolanlawson commented 8 years ago

Yup, your fix looks correct to me. Needs to be added to these lines and also needs another test. Want to contribute it? :D

Coniglioz commented 8 years ago

Ok! I'll do it :D

nolanlawson commented 8 years ago

a99028a400584b480a1adabe707bad9a50d07d10