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)⇒ undefinedget(modelName)⇒ ModelgetEmptyState()⇒ Objectsession(state)⇒ SessionmutableSession(state)⇒ SessionwithMutations()from()getDefaultState()define()
new ORM([opts])
Creates a new ORM instance.
| Param | Type | Description |
|---|---|---|
| [opts] | Object | |
| [opts.stateSelector] | function | function that given a Redux state tree |
| [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
| Param | Type | Description |
|---|---|---|
| ...models | Model | 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.
| Param | Type | Description |
|---|---|---|
| modelName | string | 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
| Param | Type | Description |
|---|---|---|
| state | Object | the state the database manages |
mutableSession(state)⇒ Session
Begins a mutable database session.
Kind: instance method of ORM
Returns: Session -
a new Session instance
| Param | Type | Description |
|---|---|---|
| state | Object | the state the database manages |
withMutations()
withMutations()Deprecated
Kind: instance method of ORM
from()
from()Deprecated
Kind: instance method of ORM
getDefaultState()
getDefaultState()Deprecated
Kind: instance method of ORM
define()
define()Deprecated
Kind: instance method of ORM