How to use the pouchdb-core.defaults function in pouchdb-core

To help you get started, we’ve selected a few pouchdb-core 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 TankerHQ / quickstart-examples / client / nodejs / hello-world / persistence.js View on Github external
PouchDB: function (dbName) {
      // Folder to store tokens for this trustchain
      const folder = `./data/${tankerConfig.trustchainId.replace(/[\/\\]/g, '_')}`;

      // Ensure folder exists
      if (!fs.existsSync(folder)) {
        fs.mkdirSync(folder);
      }

      // Apply defaults
      const PouchDB = PouchDBCore.defaults({ adapter: 'leveldb' });

      // PouchDB will now persist data in the proper folder
      return new PouchDB(`${folder}/${dbName}`);
    }
  }
github hoodiehq / hoodie / cli / parse-options.js View on Github external
options.dbUrl = createAuthDbUrl(log, options.dbUrlUsername, options.dbUrlPassword, options.dbUrl)

  if (options.dbUrl) {
    PouchDB.plugin(require('pouchdb-adapter-http'))
    dbOptions.prefix = options.dbUrl
    log.info('config', 'Storing all data in ' + options.dbUrl)
  } else if (options.inMemory) {
    PouchDB.plugin(require('pouchdb-adapter-memory'))
    config.inMemory = true
    log.info('config', 'Storing all data in memory only')
  } else {
    PouchDB.plugin(require(options.dbAdapter))
    dbOptions.prefix = path.join(config.paths.data, 'data') + path.sep
    log.info('config', 'Storing all data in ' + dbOptions.prefix + ' using ' + options.dbAdapter)
  }
  config.PouchDB = PouchDB.defaults(dbOptions)

  return config
}

pouchdb-core

The core of PouchDB as a standalone package.

Apache-2.0
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages