JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q13136F
  • License MIT

A declarative way to express queries with reselect

Package Exports

  • relational-reselect

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (relational-reselect) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

relational-reselect (💥 WIP)

Build Status Coverage Status Codacy Badge npm bundle size NPM npm

With its decarative style, this library aims to facilitate creation of complex selectors on a normalized store that imposes to perform joins, lookups, relationships, or whatever you call it !

import { createSelector } from 'reselect';
import Query from 'relational-reselect';

const ordersSelector = state => state.get('orders');
const ordersFrSelector = createSelector(
  ordersSelector,
  orders => orders.filter(order => order.get('country') === 'fr'),
);
const customersSelector = state => state.get('customers');

const salesReportFrSelector = new Query()
  .from(customersSelector, 'cust')
  .innerJoin(ordersFrSelector, 'ord')
  .on(
    tuple => tuple.getIn(['cust', 'id']) === tuple.getIn(['ord', 'customer']),
  );

salesReportFrSelector.run(state);

other examples are available on dedicated CodeSandbox

Install

npm install --save relational-reselect

API

const query = new Query()

To create a new query, this one is fair enough !

.select()

Optional step, if you want to perform cleansing or enrichment over joined data.

.from()

Required step, can consume a proper selector or another query if you want to nest theme. You must provide a data source and its alias as well.

Joins

Optional step, you can add as much data sources as you want as long as you specify how to join them

.innerJoin()

.leftJoin()

.rightJoin()

.fullJoin()

.except()

.intersect()

.union()

.cartesian()

.where()

Ordering

Optional step, it will proceed over from`` or select

State Machine Diagram

State Machine diagram

Class Diagram

Class diagram