Model
Direct Subclass:
The Model
class represents a local data resource. It provides methods to
persist changes via the API.
Static Method Summary
Static Public Methods | ||
public static |
Generate a function which returns the value of the given attribute. |
|
public static |
Generate a function which returns the value of the given has-many relationship. |
|
public static |
Generate a function which returns the value of the given has-one relationship. |
|
public static |
transformDate(value: String): Date | null Transform the given value into a Date object. |
Static Protected Methods | ||
protected static |
getIdentifier(model: Model): Object Get a resource identifier object for the given model. |
Constructor Summary
Public Constructor | ||
public |
constructor(data: Object, store: Store) |
Member Summary
Public Members | ||
public |
The resource object from the API. |
|
public |
Whether or not the resource exists on the server. |
|
public |
The time at which the model's data was last updated. Watching the value of this property is a fast way to retain/cache a subtree if data hasn't changed. |
Protected Members | ||
protected |
The data store that this resource should be persisted to. |
Method Summary
Public Methods | ||
public |
Get one of the model's attributes. |
|
public |
copyData(): * |
|
public |
Send a request to delete the resource. |
|
public |
id(): Integer Get the model's ID. |
|
public |
pushAttributes(attributes: Object) Merge new attributes into this model locally. |
|
public |
Merge new data into this model locally. |
|
public |
Merge new attributes into this model, both locally and with persistence. |
Protected Methods | ||
protected |
Construct a path to the API endpoint for this resource. |
Static Public Methods
public static attribute(name: String, transform: function): * source
Generate a function which returns the value of the given attribute.
Return:
* |
public static hasMany(name: String): Array | Boolean source
Generate a function which returns the value of the given has-many relationship.
Params:
Name | Type | Attribute | Description |
name | String |
public static hasOne(name: String): Model | Boolean | undefined source
Generate a function which returns the value of the given has-one relationship.
Params:
Name | Type | Attribute | Description |
name | String |
public static transformDate(value: String): Date | null source
Transform the given value into a Date object.
Params:
Name | Type | Attribute | Description |
value | String |
Static Protected Methods
Public Constructors
Public Members
public freshness: Date source
The time at which the model's data was last updated. Watching the value of this property is a fast way to retain/cache a subtree if data hasn't changed.
Protected Members
Public Methods
public attribute(attribute: String): * source
Get one of the model's attributes.
Params:
Name | Type | Attribute | Description |
attribute | String |
Return:
* |
public pushAttributes(attributes: Object) source
Merge new attributes into this model locally.
Params:
Name | Type | Attribute | Description |
attributes | Object | The attributes to merge. |
public pushData(data: Object) source
Merge new data into this model locally.
Params:
Name | Type | Attribute | Description |
data | Object | A resource object to merge into this model |
public save(attributes: Object, options: Object): Promise source
Merge new attributes into this model, both locally and with persistence.