Skip to content


Subversion checkout URL

You can clone with
Download ZIP


(#434) - Prefixing databases #675

wants to merge 3 commits into from

4 participants


No description provided.


Cool! It would be also useful to add a note in our documentation that _pouchSomething is reserved.


agreed, I can update this PR to do that. one concern though, I didn't prefix http databases because I thought that it would be misleading if you were trying to replicate to a remote db and couldn't because we kept prefixing the database.


Totally right. I just wanted to add this prefix so that we don't have to warn users: don't mix indexeddb with pouchdb because your indexeddb databases couldb get destroyed. Now we just warn: don't call your indexeddb __pouchdb_something (why would you even try?) (or in fact: _pouchsomething as you implemented)


cool, just making sure. i think i might change the prefix to 'pouch'. '_pouchsomething' is less readable when you're debugging


Perfect, and thanks for the feedback/review @neojski

Merged in 7dc9c26

@daleharvey daleharvey closed this

Not sure if I should re-open this or #434, or create a new this one for now.

DB prefixing is a problem in node.js, where you can specify a path to a database: if I want to open "/home/userfoo/.dbdir", adding a prefix to that is going to mess things up.

Is there any reason not to just disable this for node, and leave it enabled for other adapters?

@chesles chesles reopened this

@chesles the #434 refer to the issue that this pull request references, so its the issue that gets reopened, not the PR, its mostly github being really stupid about how it conflates pull requests and issues

@daleharvey daleharvey closed this

Got it- that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 6 deletions.
  1. +2 −0  docs/
  2. +1 −1  src/pouch.adapter.js
  3. +6 −5 src/pouch.js
2  docs/
@@ -49,6 +49,8 @@ Retrieves all databases from PouchDB. (Adapter prefix of database is included if
This method gets an existing database if one exists or creates a new one if one does not exist. You may also explicitly specify which backend you want to use for local database (e.g. `idb://dbname` or `leveldb://dbname`) but usually it is convenient to let PouchDB choose the best backend by itself.
+Note: Pouch reserves the prefix '_pouch_' for the creation of local databases -- all local databases will automatically be preprended with '_pouch_'.
var pouchdb = Pouch('test');;
2  src/pouch.adapter.js
@@ -26,7 +26,7 @@ var PouchAdapter = function(opts, callback) {
// Don't call for ALL_DBS
// saves the db's name into ALL_DBS
- if ( === Pouch.ALL_DBS) {
+ if ( === Pouch.prefix + Pouch.ALL_DBS) {
callback(err, db);
} else {, function(err) {
11 src/pouch.js
@@ -81,8 +81,9 @@ Pouch.DEBUG = false;
Pouch.adapters = {};
Pouch.plugins = {};
-Pouch.parseAdapter = function(name) {
+Pouch.prefix = '_pouch_';
+Pouch.parseAdapter = function(name) {
var match = name.match(/([a-z\-]*):\/\/(.*)/);
if (match) {
// the http adapter expects the fully qualified name
@@ -98,7 +99,7 @@ Pouch.parseAdapter = function(name) {
for (var i = 0; i < preferredAdapters.length; ++i) {
if (preferredAdapters[i] in Pouch.adapters) {
return {
- name: name,
+ name: Pouch.prefix + name,
adapter: preferredAdapters[i]
@@ -125,7 +126,7 @@ Pouch.destroy = function(name, callback) {
// call destroy method of the particular adaptor
Pouch.adapters[opts.adapter].destroy(, callback);
// remove Pouch from allDBs
Pouch.removeFromAllDbs(opts, cb);
@@ -167,7 +168,7 @@ Pouch.removeFromAllDbs = function(opts, callback) {
Pouch.adapter = function (id, obj) {
@@ -192,7 +193,7 @@ Pouch.realDBName = function(adapter, name) {
return [adapter, "://", name].join('');
Pouch.allDBName = function(adapter) {
- return [adapter, "://", Pouch.ALL_DBS].join('');
+ return [adapter, "://", Pouch.prefix + Pouch.ALL_DBS].join('');
}; = function(opts, callback) {
Something went wrong with that request. Please try again.