Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pouchdb-all-dbs appears to ignore defaults #25

Open
flimzy opened this issue Feb 11, 2017 · 1 comment
Open

pouchdb-all-dbs appears to ignore defaults #25

flimzy opened this issue Feb 11, 2017 · 1 comment

Comments

@flimzy
Copy link

flimzy commented Feb 11, 2017

Please advise me if I'm doing something wrong. My goal is to use 'allDbs' in my unit tests, which use the memdown adaptor. But I cannot determine how to get this to work. I am trying to the PouchDB.defaults() method to set the adaptor, which appears to work for most normal functions, but this plugin appears to ignore it.

Here is a minimal reproduction case. Save this file as 'test.js' in an empty directory:

var PouchDB = require('pouchdb');
require('pouchdb-all-dbs')(PouchDB);
var MemDB = PouchDB.defaults({
    'db': require('memdown')
});
MemDB.allDbs(function(error, result) {
    console.log(result);
});

Then install dependencies:

npm install pouchdb pouchdb-all-dbs memdown

Verify that we have the proper files in the test direcotry:

$ ls -la
total 28
drwxr-sr-x   3 jonhall jonhall  4096 Feb 11 19:20 .
drwxrwsr-x 132 jonhall jonhall 16384 Feb 11 19:19 ..
drwxr-sr-x 206 jonhall jonhall  4096 Feb 11 19:20 node_modules
-rw-r--r--   1 jonhall jonhall   203 Feb 11 19:19 test.js

Then run the test script:

$ node ./test.js
[]

No output, as expected, but now do another ls:

$ ls -la
total 32
drwxr-sr-x   4 jonhall jonhall  4096 Feb 11 19:21 .
drwxrwsr-x 132 jonhall jonhall 16384 Feb 11 19:19 ..
drwxr-sr-x 206 jonhall jonhall  4096 Feb 11 19:20 node_modules
drwxr-sr-x   2 jonhall jonhall  4096 Feb 11 19:21 pouch__all_dbs__
-rw-r--r--   1 jonhall jonhall   203 Feb 11 19:19 test.js

Notice the new pouch__all_dbs__ directory, thus proving that allDbs() is still using the filesystem instead of memdown. Is this a bug? Is there a workaround?

@nolanlawson
Copy link
Member

Thanks for filing; yes it doesn't surprise me that this plugin doesn't play well with defaults. 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants