Bulbat
The name is from random generated Pokémon, between Bulbasaur and Golbat.
This is in-memory quick storage that could be synced to the disk if neaded inside an encrypted file.
WARNING
The current implementation is pretty basic in terms of encryption. So don't put any sensitive data
Usage
Install the package with
npm install --save bulbat
Import and use
import { Database } from 'bulbat';
const db = new Database();
const post = {
id: 42,
title: 'Welcome to my blog!',
content: '...'
};
db.collection('posts').insert(post);
db.collection('posts').data.map((post) => {
console.log(post);
});
You could use the Collection only without the need of the
Database
instance:
import { Collection } from 'bulbat'
const posts = new Collection('posts');
posts.insert();
posts.data.map((post) => {
console.log(post)
});
The collection provide an reduce
method that could be used to sort or change the content of the collection,
internal state. Right now the only way to make bulk actions to the storage.
import { Collection } from 'bulbat';
const col = new Collection('posts');
col.reduce((result, post) => {
if (post.status !== 'deleted') {
result.push(post);
}
return result;
});
col.data
Development
npm install
To start development run:
npm run develop
Other commands:
npm run format
npm run lint
npm run build
npm run test
npm run test:watch