redux-eloquent
v1.0.1
Published
Query and mutate redux store in ORM style that you love
Downloads
4
Readme
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()
}
}