Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

flex-docstore

JSON Document store with flexible backend (files on fs, PouchDB, etc)

store, persistence, kv, json, document, decentralized, key, store, value

readme

Flexible Document Store (flex-docstore)

JSON Document store with flexible backend (files on fs, PouchDB, etc)

Table of Contents

Security

TBD

Background

TBD

Install

Requires Node.js 8.10+.

npm install flex-docstore

Usage

Requiring

const { FlexDocStore } = require('flex-docstore')

FS Backend (one file per object)

const store = FlexDocStore.using('files', { dir: './db' })

Mock Backend (for unit testing)

const store = FlexDocStore.using('mock')

API

The storage API is based on the PouchDB API

  • post is not implemented (use uuid + put)
get

async get (key)

Retrieves the document at a given key (null if not found).

const data = await store.get('key1')
put

async put (key, value)

Writes a document to a given key.

await store.put('key1', doc)
remove

async remove (key)

Deletes a document.

await store.remove('key1')
allDocs

async allDocs ()

Lists all documents in the store.

await store.allDocs({ include_docs: false })

Contribute

PRs accepted.

Code style: Standard JS

Comments style: JSDoc.

README style: If editing the Readme, please conform to the standard-readme specification.

License

MIT LICENSE © Interop Alliance, Dmitri Zagidulin

changelog

Changelog

v1.0.0 - 2021-12-29

Changed

  • BREAKING: Add validation to FlexFileBackend constructor.

v0.1.1 - 2019-11-27

Changed

  • Fix - do not instantiate using modelClass if no doc is found.

v0.1.0 - 2019-11-03

Changed

  • (BREAKING) Changed export signature to const { FlexDocStore } = require('flex-docstore')
  • (BREAKING) Changed return value of allDocs() to closer match Pouch API.
  • Minor internal renames and refactoring.

v0.0.1

  • Initial version