bouchon-toolbox
A set of tools for bouchon.
What is a selector?
A selector is a function that returns a subset of an existing collection.
They are composable and performant (by using memoization).
bouchon is providing createSelector
from reselect.
filterRows
filterRows
is useful to filter an array easily.
Imagine that you want to retrieve the books of an author:
; const selectors = {}; selectors statebooks; selectors ;
It could be written easier:
;const filterRows = selectors; const selectors = {}; selectors statebooks;selectors ;
filterRows
returns a selector that can be use inside an another selector.
For example, if you want to return the books of an author for a specific years
(it can be the response of an url like /books/:author/:date
), you can do like this:
;const filterRows = selectors; const selectors = {}; selectors statebooks;selectors ;selectors ;
extendRows
extendRows
is useful to extend a collection with data of an another collection.
For example, imagine that your want the author data with your books collection:
const selectors = {}; selectors statebooks;selectors stateauthors; selectors ;
It will return books with their author by comparing books.author_id
with authors.id
(similar to a SQL join query).
Installation
npm install bouchon-toolbox