keyv-pouchdb

0.1.0-alpha.2 • Public • Published

keyv+ PouchDB logo
keyv-pouchdb

Third party PouchDB storage adapter for Keyv.

Build Status npm

Motivation

Leveraging pouchdb-lru-cache as a keyv-storage-adapter that complies with the api specs.

Installation

$ npm install --save keyv-pouchdb
 
# Then add a pouchdb adapter 
$ npm install pouchdb-adapter-memory --save
$ npm install pouchdb-adapter-http --save
$ npm install pouchdb-adapter-node-websql --save

Usage

const KeyvPouchDB = require("keyv-pouchdb");
const Keyv = require("keyv");
 
const store = new KeyvPouchDB({
  // default options
  maxCacheSize: 5000000, // maximum cache size in bytes. 0 for limitless [memory only]
  overwriteExisting: false, // replace existing entries
  pouchDB: {
    // pouchDB configuration options
    adapter: "memory", // pouchdb adapter
    database: "keyv-pouchdb-cache", // database (string | uri)
    remoteConfig: {} // configuration options for remote database
  }
});
 
/*
 * or connect to a remote instance
 * 
 * npx pouchdb-server --port 3000 --in-memory
 * 
 */
new KeyvPouchDB("http://localhost:3000/keyv-pouchdb-cache"); // loads `pouchdb-adapter-http`
 
/*
 * 
 * or maybe even sqlite3
 * 
*/
new KeyvPouchDB("database.db"); // loads `pouchdb-adapter-node-websql`
 
/****************************/
 
const keyv = new Keyv({ store });
 

License

MIT © wmik

Package Sidebar

Install

npm i keyv-pouchdb

Weekly Downloads

2

Version

0.1.0-alpha.2

License

MIT

Unpacked Size

6.9 kB

Total Files

4

Last publish

Collaborators

  • wmik