How to use pouchdb-wrappers - 10 common examples

To help you get started, we’ve selected a few pouchdb-wrappers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pouchdb / pouchdb-server / packages / node_modules / pouchdb-auth / lib / index.js View on Github external
return utils.nodify(Promise.resolve().then(function () {
    // add wrappers and make system db
    if (!info.isOnlineAuthDB) {
      wrappers.installWrapperMethods(args.db, writeWrappers);
      systemDB.installSystemDBProtection(args.db);

      // store validation doc
      return args.db.put(designDoc);
    }
  }).catch(function (err) {
    /* istanbul ignore if */
github pouchdb / pouchdb-server / packages / node_modules / express-pouchdb / lib / routes / db.js View on Github external
app.dbWrapper.registerWrapper(function (name, db, next) {
    // db.info() should just return the non-uri encoded db name
    wrappers.installWrapperMethods(db, {
      info: function (orig) {
        return orig().then(function (info) {
          info.db_name = decodeURIComponent(info.db_name);
          return info;
        });
      }
    });

    return next();
  });
github pouchdb / pouchdb-server / packages / node_modules / express-pouchdb / lib / index.js View on Github external
start: function (PouchDB) {
      // add PouchDB.new() - by default it just returns 'new PouchDB()'
      // also re-adds PouchDB.destroy(), see for reasoning:
      // https://github.com/pouchdb/express-pouchdb/pull/231#issuecomment-136095649
      wrappers.installStaticWrapperMethods(PouchDB, {});

      return Promise.resolve().then(function () {
        return PouchDB.allDbs();
      }).catch(function () {
        require('pouchdb-all-dbs')(PouchDB);
      });
    }
  });
github pouchdb / pouchdb-server / packages / node_modules / express-pouchdb / lib / routes / db.js View on Github external
start: function (PouchDB) {
      // PouchDB.allDbs() should return the non-uri encoded db name
      wrappers.installStaticWrapperMethods(PouchDB, {
        allDbs: function (orig) {
          return orig().then(function (dbs) {
            return dbs.map(decodeURIComponent);
          });
        }
      });
    }
  });
github pouchdb / pouchdb-server / dist / http-pouchdb.js View on Github external
xhr.open('GET', url + '_all_dbs');
      xhr.send();
    });
  };

  var HTTPPouchDB = PouchDB.defaults(extend({}, opts, {
    prefix: url
  }));

  // https://github.com/marten-de-vries/http-pouchdb/issues/1
  HTTPPouchDB.adapters.http.use_prefix = false;

  /* istanbul ignore next */
  // noop that can be 'wrapped' soon
  HTTPPouchDB.allDbs = function () {};
  wrappers.installStaticWrapperMethods(HTTPPouchDB, api);

  HTTPPouchDB.isHTTPPouchDB = true;
  return HTTPPouchDB;
};
github pouchdb / pouchdb-server / packages / node_modules / pouchdb-auth / lib / index.js View on Github external
if (i === -1) {
    throw new Error("Not an authentication database.");
  }
  utils.dbData.dbs.splice(i, 1);
  var info = utils.dbData.dataByDBIdx.splice(i, 1)[0];

  for (var name in api) {
    /* istanbul ignore else */
    if (api.hasOwnProperty(name)) {
      delete db[name];
    }
  }

  if (!info.isOnlineAuthDB) {
    systemDB.uninstallSystemDBProtection(db);
    wrappers.uninstallWrapperMethods(db, writeWrappers);
  }

  Validation.uninstallValidationMethods.call(db);
};
github pouchdb / npm-browser / scripts / deps / pouchdb.transform-pouch.js View on Github external
return origOn.apply(changes, [event, function (res) {
          listener(modifyChanges(res));
        }]);
      }
      return origOn.apply(changes, [event, listener]);
    };

    var origThen = changes.then;
    changes.then = function (resolve, reject) {
      return origThen.apply(changes, [function (res) {
        resolve(modifyChanges(res));
      }, reject]);
    };
    return changes;
  };
  wrappers.installWrapperMethods(db, handlers);
};
github pouchdb-community / transform-pouch / dist / pouchdb.transform-pouch.js View on Github external
});
          });
        }]);
      }
      return origOn.apply(changes, [event, listener]);
    };

    var origThen = changes.then;
    changes.then = function (resolve, reject) {
      return origThen.apply(changes, [function (res) {
        modifyChanges(res).then(resolve, reject);
      }, reject]);
    };
    return changes;
  };
  wrappers.installWrapperMethods(db, handlers);
};
github pouchdb-community / transform-pouch / index.js View on Github external
});
          });
        }]);
      }
      return origOn.apply(changes, [event, listener]);
    };

    var origThen = changes.then;
    changes.then = function (resolve, reject) {
      return origThen.apply(changes, [function (res) {
        return modifyChanges(res).then(resolve, reject);
      }, reject]);
    };
    return changes;
  };
  wrappers.installWrapperMethods(db, handlers);
};
github pouchdb / pouchdb-server / packages / node_modules / express-pouchdb / lib / index.js View on Github external
app.dbWrapper.registerWrapper(function (name, db, next) {
    //'fix' the PouchDB api (support opts arg everywhere)
    function noop(orig) {
      return orig();
    }
    var wrapperMethods = {};
    ['info', 'removeAttachment'].forEach(function (name) {
      wrapperMethods[name] = noop;
    });
    wrappers.installWrapperMethods(db, wrapperMethods);
    return next();
  });

pouchdb-wrappers

Makes wrapping PouchDB functions a lot easier.

Apache-2.0
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis