How to use sublevel-pouchdb - 3 common examples

To help you get started, we’ve selected a few sublevel-pouchdb 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 stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / src / index.js View on Github external
var leveldown = opts.db;

  var dbStore;
  var leveldownName = functionName(leveldown);
  if (dbStores.has(leveldownName)) {
    dbStore = dbStores.get(leveldownName);
  } else {
    dbStore = new Map();
    dbStores.set(leveldownName, dbStore);
  }
  if (dbStore.has(name)) {
    db = dbStore.get(name);
    afterDBCreated();
  } else {
    dbStore.set(name, sublevel(levelup(name, opts, function (err) {
      /* istanbul ignore if */
      if (err) {
        dbStore.delete(name);
        return callback(err);
      }
      db = dbStore.get(name);
      db._docCount  = -1;
      db._queue = new Deque();
      /* istanbul ignore else */
      if (opts.migrate) { // migration for leveldown
        migrate.toSublevel(name, db, afterDBCreated);
      } else {
        afterDBCreated();
      }
    })));
  }
github stockulus / pouchdb-react-native / packages / pouchdb-adapter-leveldb-core-rn / src / index.js View on Github external
var leveldown = opts.db

  var dbStore
  var leveldownName = functionName(leveldown)
  if (dbStores.has(leveldownName)) {
    dbStore = dbStores.get(leveldownName)
  } else {
    dbStore = new Map()
    dbStores.set(leveldownName, dbStore)
  }
  if (dbStore.has(name)) {
    db = dbStore.get(name)
    afterDBCreated()
  } else {
    dbStore.set(name, sublevel(levelup(name, opts, function (err) {
      /* istanbul ignore if */
      if (err) {
        dbStore.delete(name)
        return callback(err)
      }
      db = dbStore.get(name)
      db._docCount = -1
      db._queue = new Deque()
      afterDBCreated()
    })))
  }

  function afterDBCreated () {
    stores.docStore = db.sublevel(DOC_STORE, {valueEncoding: safeJsonEncoding})
    stores.bySeqStore = db.sublevel(BY_SEQ_STORE, {valueEncoding: 'json'})
    stores.attachmentStore =
github pouchdb / pouchdb / packages / node_modules / pouchdb-adapter-leveldb-core / src / index.js View on Github external
var leveldown = opts.db;

  var dbStore;
  var leveldownName = functionName(leveldown);
  if (dbStores.has(leveldownName)) {
    dbStore = dbStores.get(leveldownName);
  } else {
    dbStore = new Map();
    dbStores.set(leveldownName, dbStore);
  }
  if (dbStore.has(name)) {
    db = dbStore.get(name);
    afterDBCreated();
  } else {
    dbStore.set(name, sublevel(levelup(leveldown(name), opts, function (err) {
      /* istanbul ignore if */
      if (err) {
        dbStore.delete(name);
        return callback(err);
      }
      db = dbStore.get(name);
      db._docCount  = -1;
      db._queue = new Deque();
      /* istanbul ignore else */
      if (typeof opts.migrate === 'object') { // migration for leveldown
        opts.migrate.doMigrationOne(name, db, afterDBCreated);
      } else {
        afterDBCreated();
      }
    })));
  }

sublevel-pouchdb

Fork of level-sublevel with ony the subset of the API that PouchDB uses

Apache-2.0
Latest version published 5 months ago

Package Health Score

88 / 100
Full package analysis

Popular sublevel-pouchdb functions

Similar packages