pouchdb-community/pouchdb-all-dbs

pouchdb-all-dbs appears to ignore defaults

Open

#25 opened on Feb 11, 2017

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (16 forks)github user discovery
bughelp wanted

Repository metrics

Stars
 (29 stars)
PR merge metrics
 (PR metrics pending)

Description

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?

Contributor guide