Model
Extends:
Direct Subclass:
A model that has attributes synced with the database.
Example:
export class Box extends Model {
get label() {}
get articleNumber() {}
}
Constructor Summary
Public Constructor | ||
public |
constructor(id: String, data: Object, options: Object): Model Creates a new instance of a model. |
Method Summary
Public Methods | ||
public |
Check if the model has been synchonized with the database |
Inherited Summary
From class PrioritisedObject | ||
public get |
dataSource: * |
|
public get |
id: * |
|
public set |
id: * |
|
public get |
priority: * Priority (positioning) of the object in the dataSource |
|
public set |
priority: * |
|
public |
disableChangeListener(): void Disables pushes of local changes to the dataSource, and stops event emits that refer to the model's data. |
|
public |
enableChangeListener(): void Enables pushes of local changes to the dataSource, and enables event emits that refer to the model's data. The change listener is active by default, so you'll only need to call this method if you've previously called disableChangeListener(). |
|
public |
Removes subscription to events emitted by this PrioritisedArray. |
|
public |
Subscribes to events emitted by this PrioritisedArray. |
|
public |
Subscribes to the given event type exactly once; it automatically unsubscribes after the first time it is triggered. |
|
public |
remove(): void Deletes the current object from the dataSource, and clears itself to free memory. |
|
public |
transaction(method: Function): void Allows multiple modifications to be made to the model without triggering dataSource pushes and event emits for each change. |
Public Constructors
public constructor(id: String, data: Object, options: Object): Model source
Creates a new instance of a model.
Override:
PrioritisedObject#constructorParams:
Name | Type | Attribute | Description |
id | String | Optional: The identifier for this model. For a user model this might be a user ID, for example. It is used to build the path to the dataSource. This path is <root>/<model name appended with 's'>/<id>. If no id is given, a randomly generated one will be pushed to the dataSource. You can use this for creating new objects in the dataSource. |
|
data | Object | Optional: The initial data to fill the model with. The model will be extended with any properties present in the data parameter. |
|
options | Object | Optional: Additional options. Currently used is "dataSnapshot", which if present is used to fetch the initial model data. If not present, the model will add a one-time subscription to the dataSource to fetch initial data. |