Hacksaw is a data store library for javascript. You can store all the states
along the app life time with view stores.
View Store
The idea behind Hacksaw is contextual store which means you have one store which
you can generate sub stores using contexts and also all model instances will be
shared among contexts.
Installation
npm install hacksaw --save
Examples
import { createStore } from 'hacksaw';
const store = createStore({
tables: {
products: {},
users: {
relations: {
products: {
type: Array,
table: 'products'
}
}
}
}
});
store.products.all;
const bestViewStore = store.view('best');
const trendingViewStore = store.view('trending');
bestViewStore.products.all;
trendingViewStore.products.all;
bestViewStore.products.put({ id: 1, name: 'A book' });
trendingViewStore.products.put({ id: 2, name: 'Trending book' });
store.products.all
bestViewStore.all;
const anotherViewStore = store.view('another-context');
anotherViewStore.products.populate(i => i.id === 1);
anotherViewStore.products.first
trendingViewStore.clean();
trendingViewStore.products.all;
store.products.all
store.users.put({ id: 1, name: 'Plato', products: [{ id: 1, name: 'Apology' }] });
store.users.first;
store.products.all;