Redux-ORM

Redux-ORM

  • Getting Started
  • Docs
  • API
  • GitHub

›API Reference

Introduction

  • Getting Started
  • Installation

Basics

  • Quick Start
  • Relational Fields
  • Reducers
  • Selectors
  • Usage with React

Advanced

  • Complex Selectors
  • Custom Reducer

API Reference

  • API Reference
  • ORM
  • Model
  • QuerySet
  • Session
  • Fields
  • Redux

ORM

ORM - the Object Relational Mapper.

Use instances of this class to:

  • Register your [Model](Model) classes using [register](#ORM+register)
  • Get the empty state for the underlying database with [getEmptyState](#ORM+getEmptyState)
  • Start an immutable database session with [session](#ORM+session)
  • Start a mutating database session with [mutableSession](#ORM+mutableSession)

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

Kind: global class

  • ORM
    • new ORM([opts])
    • register(...models) ⇒ undefined
    • get(modelName) ⇒ Model
    • getEmptyState() ⇒ Object
    • session(state) ⇒ Session
    • mutableSession(state) ⇒ Session
    • withMutations()
    • from()
    • getDefaultState()
    • define()

new ORM([opts])

Creates a new ORM instance.

ParamTypeDescription
[opts]Object
[opts.stateSelector]function

function that given a Redux state tree
will return the ORM state's subtree,
e.g. state => state.orm
(necessary if you want to use selectors)

[opts.createDatabase]function

function that creates a database

register(...models)⇒ undefined

Registers a [Model](Model) class to the ORM.

If the model has declared any ManyToMany fields, their
through models will be generated and registered with
this call, unless a custom through model has been specified.

Kind: instance method of ORM

ParamTypeDescription
...modelsModel

a Model class to register

get(modelName)⇒ Model

Gets a [Model](Model) class by its name from the registry.

Kind: instance method of ORM
Returns: Model -

the Model class, if found


Throws:

  • -

    If [Model](Model) class is not found.

ParamTypeDescription
modelNamestring

the name of the Model class to get

getEmptyState()⇒ Object

Returns the empty database state.

Kind: instance method of ORM
Returns: Object -

the empty state

session(state)⇒ Session

Begins an immutable database session.

Kind: instance method of ORM
Returns: Session -

a new Session instance

ParamTypeDescription
stateObject

the state the database manages

mutableSession(state)⇒ Session

Begins a mutable database session.

Kind: instance method of ORM
Returns: Session -

a new Session instance

ParamTypeDescription
stateObject

the state the database manages

withMutations()

Deprecated

Kind: instance method of ORM

from()

Deprecated

Kind: instance method of ORM

getDefaultState()

Deprecated

Kind: instance method of ORM

define()

Deprecated

Kind: instance method of ORM

Last updated on 12.1.2020
← API ReferenceModel →
  • new ORM([opts])
  • register(...models)⇒ undefined
  • get(modelName)⇒ Model
  • getEmptyState()⇒ Object
  • session(state)⇒ Session
  • mutableSession(state)⇒ Session
  • withMutations()
  • from()
  • getDefaultState()
  • define()
Redux-ORM
Docs
Getting StartedQuick StartAdvanced scenarios
Community
Stack OverflowGitter
More
GitHubStar
Copyright © 2020 Redux-ORM documentation authors.
Some icons copyright Font Awesome.