Model

Model

Active Redux Model

Constructor

new Model()

Source:

Members

attributes

Attributes of a model, for which methods will be defined
Source:
Example
import Model, { Attr } from 'active-redux';

const Person = Model.define('people', class Person {
  static attributes = {
    name: Attr.string(),
  }
});

const joe = new Person({ attributes: { name: "Joe" } });
joe.name // => "Joe"

id

Source:

type

Source:

Methods

(static) all() → {Promise.<Array.<this>>}

Gets all of that resource
Source:
Returns:
Type:
Promise.<Array.<this>>
Array of model instances
Example
Person.all()
// => Promise<Array<Person>>

(static) find(query, optionsopt) → {Promise.<(this|null)>}

Gets one of that resource
Source:
Parameters:
Name Type Attributes Description
query Object Query for the store
options Object <optional>
Name Type Attributes Description
remote boolean <optional>
Call to API if no records found?
Returns:
Type:
Promise.<(this|null)>
A model instance
Example
Person.find({ id: 5 })
// => Promise<Person>

(static) where(query, optionsopt) → {Promise.<Array.<this>>}

Queries the store for that resource
Source:
Parameters:
Name Type Attributes Description
query Object Query for the store
options Object <optional>
Name Type Attributes Description
remote boolean <optional>
Call to API if no records found?
Returns:
Type:
Promise.<Array.<this>>
Array of model instances
Example
Person.where({ name: "Joe" })
// => Promise<Array<Person>>