pouchdb-doc-api
PouchDB plugin for a document-bound API
Usage
var db = 'mydb' var docId = 'mydocid' // can be any valid do idvar api = db // creates or replaces existing document with _id: mydocidapi
🔏📃 Security notice
In case you want to store sensitive data, be aware that PouchDB does not remove data but creates new revisions. The older revisions remain accessible.
The only exception to this are local documents
with an docId prefixed by _local/
. So say you want to store an API key or
session ID using pouchdb-doc-api
, I strongly recommend to us a docId like
_local/session
. Full usage example
var db = 'mydb'var api = db
api.set
and api.unset
will no remove previously stored data without leaving
revisions that could be recovered.
API
Factory
Returns the store API bound to the document with the passed id
db
Argument | Type | Description | Required |
---|---|---|---|
id |
String | ID of the document the store API should be bound to. | Yes |
Example
var db = 'mydb'var store = db
store.get()
Resolves with the document properties, without the _id
and _rev
properties.
store
store.set()
Replaces all current document properties with the once passed. _id
and _rev
properties are ignored. Resolves with the document properties.
store
store.unset()
Removes document from the database using PouchDB’s db.remove()
method. Resolves without arguments.
store