Skip to content

Commit

Permalink
(pouchdb#1261) - switch to sublevel instead of a folder of dbs, also …
Browse files Browse the repository at this point in the history
…fix some ids issues
  • Loading branch information
calvinmetcalf authored and daleharvey committed Feb 23, 2014
1 parent 0d696aa commit b53ceda
Show file tree
Hide file tree
Showing 30 changed files with 242 additions and 233 deletions.
4 changes: 2 additions & 2 deletions lib/adapters/http.js
Expand Up @@ -219,9 +219,9 @@ function HttpPouch(opts, callback) {
};

// The HttpPouch's ID is its URL
api.id = function (callback) {
api.id = utils.toPromise(function (callback) {
callback(null, genDBUrl(host, ''));
};
});

api.request = utils.toPromise(function (options, callback) {
if (!api.taskqueue.ready()) {
Expand Down
12 changes: 6 additions & 6 deletions lib/adapters/idb.js
Expand Up @@ -103,11 +103,11 @@ function IdbPouch(opts, callback) {

req.onsuccess = function (e) {
var meta = e.target.result || {id: META_STORE};
if (name + '_id' in meta) {
instanceId = meta[name + '_id'];
if (name in meta) {
instanceId = name;
} else {
instanceId = utils.uuid();
meta[name + '_id'] = instanceId;
instanceId = name;
meta[name] = instanceId;
txn.objectStore(META_STORE).put(meta);
}

Expand Down Expand Up @@ -136,13 +136,13 @@ function IdbPouch(opts, callback) {

// Each database needs a unique id so that we can store the sequence
// checkpoint without having other databases confuse itself.
api.id = function idb_id(callback) {
api.id = utils.toPromise(function idb_id(callback) {
if (!instanceId) {
idRequests.push(callback);
} else {
callback(null, instanceId);
}
};
});

api._bulkDocs = function idb_bulkDocs(req, opts, callback) {
var newEdits = opts.new_edits;
Expand Down

0 comments on commit b53ceda

Please sign in to comment.