Socket
Socket
Sign inDemoInstall

pouchdb-doc-api

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pouchdb-doc-api

PouchDB plugin for a document-bound API


Version published
Weekly downloads
11
increased by10%
Maintainers
1
Install size
21.3 kB
Created
Weekly downloads
 

Readme

Source

pouchdb-doc-api

PouchDB plugin for a document-bound API

Build Status Coverage Status Dependency Status devDependency Status

Usage

var db = new PouchDB('mydb')

var docId = 'mydocid' // can be any valid do id
var api = db.doc(docId)

// creates or replaces existing document with _id: mydocid
api.set({foo: 'bar'})

.then(() => {
  // loads document with _id: mydocid
  return api.get()
})

.then((doc) => {
  // removes document with _id: mydocid
  return api.unset()
})

🔏📃 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 = new PouchDB('mydb')
var api = db.doc('_local/session')

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.doc(id)
ArgumentTypeDescriptionRequired
idStringID of the document the store API should be bound to.Yes

Example

var db = new PouchDB('mydb')
var store = db.doc('mydocid')

store.get()

Resolves with the document properties, without the _id and _rev properties.

store.get().then((properties) => {})

store.set()

Replaces all current document properties with the once passed. _id and _rev properties are ignored. Resolves with the document properties.

store.set({foo: 'bar'}).then((properties) => {})

store.unset()

Removes document from the database using PouchDB’s db.remove() method. Resolves without arguments.

store.unset().then(() => {})

Similar projects

License

Apache 2.0

Keywords

FAQs

Last updated on 09 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc