@rappopo/dab-memory
v0.6.11
Published
An in-memory data access layer for @rappopo/dab
Downloads
38
Maintainers
Readme
@rappopo/dab-memory
A Rappopo DAB implementation for in-memory datastore, powered by Lodash and lodash-query.
Installation
Simply invoke this command in your project folder:
$ npm install --save @rappopo/dab-memory
And within your script:
const DabMemory = require('@rappopo/dab-memory')
const dab = new DabMemory()
// prepare collections
dab.createCollection({ name: 'test' })
.then(result => {
return dab.bulkCreate(data, { collection: 'test' })
})
...
// lets dab!
dab.findOne('my-doc', 'test').then(function(doc) { ... })
Options
Currently, no options necessary.
Features
Data is internally saved as collections as follows:
dab.data.<collection-name> = [
{ _id: "key1", name: "name1", ... },
{ _id: "key2", name: "name2", ... }
]
To enforce structured data throughout DAB and use features provided by collections, you need to createCollection ()
with your custom fields as explained here
- [x] find
- [x] findOne
- [x] create
- [x] update
- [x] remove
- [x] bulkCreate
- [x] bulkUpdate
- [x] bulkRemove
- [x] copyFrom
- [x] copyTo
- [x] createCollection
- [x] renameCollection
- [x] removeCollection