Question

I'm using PouchDB with nodejs. When creating a database, a directory is created with the name of the database. How can I change where this directory is created?

Was it helpful?

Solution

You can currently specify the directory of the db file when you open the database

new PouchDB('~/myapp/db/');

We are considering changing the API @ https://github.com/daleharvey/pouchdb/issues/998 so I would also watch that for changes

OTHER TIPS

I'm guessing you're using PouchDB with LevelDB. From the source code of PouchDB, this looks like it is impossible at the moment, as PouchDB uses the database name for the directory name:

fs.stat(opts.name, function(err, stats) {
  if (err && err.code == 'ENOENT') {
    // db directory doesn't exist
    fs.mkdir(opts.name, initstores);
  }
  else if (stats.isDirectory()) {
    initstores();
  }
  else {
    // error
  }
}

and here is the relevant source code that matches a database identifier with a database name and database type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top