redux-eloquent

1.0.1 • Public • Published

redux-eloquent

redux-eloquent allows you to query and mutate your redux store in ORM style.

Usage

This simple example assumes you are familiar with using react redux and react-redux.

// Your models.js
import { defineModel, primary, id } from 'redux-eloquent'
 
export const Author = defineModel('authors', {
  id,           // shorthand for id: primary(Number)
  name: String
})
 
export const Book = defineModel('books', {
  isbn: primary(String),
  title: String,
  author: Author
})
// Your dispatch function, e.g. the callback of a request
somehowRequestBooks()
  .then(result => {
      Book(dispatch).save(result)
  })
// Your component
function mapState2Props(state) {
  return {
    allBooks: Book(state).all()
  }
}

/redux-eloquent/

    Package Sidebar

    Install

    npm i redux-eloquent

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • sevenoutman