Global

Members

(constant) ORM

ORM - the Object Relational Mapper.

Use instances of this class to:

Internally, this class handles generating a schema specification from models to the database.

Source:

Methods

createSelector(orm, …args) → {function}

Returns a memoized selector based on passed arguments. This is similar to reselect's createSelector, except you can also pass a single function to be memoized.

If you pass multiple functions, the format will be the same as in reselect. The last argument is the selector function and the previous are input selectors.

When you use this method to create a selector, the returned selector expects the whole redux-orm state branch as input. In the selector function that you pass as the last argument, you will receive session argument (a Session instance) followed by any input arguments, like in reselect.

This is an example selector:

// orm is an instance of ORM
const bookSelector = createSelector(orm, session => {
    return session.Book.map(book => {
        return Object.assign({}, book.ref, {
            authors: book.authors.map(author => author.name),
            genres: book.genres.map(genre => genre.name),
        });
    });
});

redux-orm uses a special memoization function to avoid recomputations. When a selector runs for the first time, it checks which Models' state branches were accessed. On subsequent runs, the selector first checks if those branches have changed -- if not, it just returns the previous result. This way you can use the PureRenderMixin in your React components for performance gains.

Parameters:
Name Type Attributes Description
orm ORM

the ORM instance

args function <repeatable>

zero or more input selectors and the selector function.

Source:
Returns:

memoized selector

Type
function