sengi-docstore-mem
v14.0.0
Published
An in-memory document store for Sengi.
Downloads
16
Readme
Sengi DocStore Mem
This package is part of the Sengi family.
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.