sengi-docstore-mem
TypeScript icon, indicating that this package has built-in type declarations

14.0.0 • Public • Published

Sengi DocStore Mem

This package is part of the Sengi family.

npm

An in-memory implementation of the Sengi document store interface.

Installation

npm install sengi-docstore-mem

Usage

The MemDocStore implements the DocStore interface defined in sengi-interfaces.

To instantiate a MemDocStore you have to provide the following parameters:

  • docs - An array of Doc objects.

  • generateDocVersionFunc - A function () => string that returns a string of random characters.

const memDocStore = new MemDocStore({
    docs: [],
    generateDocVersionFunc: () => crypto.randomBytes(Math.ceil(10)).toString('hex').slice(0, 20)
  })

This example uses the standard NodeJs crypto library to produce a string of 20 random hex characters for generateDocVersionFunc.

Limitations

This provider will not persist any changes because all the operations occur on a Doc's array in-memory.

This provider does not support indexes and cannot be scaled to multiple nodes.

It is great for testing purposes but probably not useful in production.

Development

Tests are written using Jest with 100% coverage.

npm test

Continuous Deployment

Any pushes or pull-requests on non-master branches will trigger the test runner.

Any pushes to master will cause the family of libraries to be re-published.

Readme

Keywords

none

Package Sidebar

Install

npm i sengi-docstore-mem

Weekly Downloads

1

Version

14.0.0

License

MIT

Unpacked Size

21.6 kB

Total Files

7

Last publish

Collaborators

  • karlhulme