PouchQ
Simplified interactions with PouchDB. These were developed for a specific project but have mostly been generalized for usage elsewhere.
npm i -S pouchq
Usage
You'll need to install and create a PouchDB database first. For example:
npm i pouchdb
// script.jsconst PouchDB = ;const db = 'my_db';
This library simplifies managing large changes with a database. Everything returns a Promise
. Examples assume availability of await
and async
.
// script.jsconst PouchDB = ;const PouchQ = ; const db = 'my_db';const pq = ; // you can overwrite db in some commands
Set all instances of key to value.
pq;
Get or create a doc. Makes the assumption that docs hold values on a key called value
.
const doc = await pq
Delete all docs in a database (from the index, not from disk).
pq;
Get docs from a response.
const docs = await db;
Remove ._id
, ._rev
from docs. Also makes sure .value
is a number (which is probably too specific for most projects).
const docs = await db;