DataRecord
Direct Subclass:
DataRecord class.
Example:
API:
->constructor(arg_collection, arg_id, arg_attributes)
->get_collection():DataCollection - get record collection.
->get_type():string - get record type.
->get_id():string - get record id.
->get_id_field_name():string - get record id.
->get_attributes():Immutable.Map - get record attributes.
->set(arg_attribute_name, arg_attribute_value):boolean - set an attribute value.
->get(arg_attribute_name):any - get an attribute value.
->save():Promise - save all changed attributes to the collection store.
->rollback():boolean - disguard any unsaved changed attributes.
->remove():Promise - remove record from collection store.
->reload():Promise - restore attributes from collection store.
->serialize():string - transform attributes map to a string.
->deserialize(string):boolean - load attributes from a string.
->fill(arg_datas):boolean - fill attributes with given datas.
->clear():boolean - fill attributes with default datas.
Constructor Summary
Public Constructor | ||
public |
constructor(arg_data_collection: DataCollection, arg_id: string, arg_attributes: object | Immutable.Map): nothing Data record class, contains one collection item attributes. |
Member Summary
Public Members | ||
public |
Class type flag. |
Private Members | ||
private |
Record attributes map. |
|
private |
Datas collection instance. |
|
private |
_dirty_attributes: array Record dirty attributes names. |
|
private |
Record has dirty attributes values flag. |
|
private |
Record unique identifier. |
|
private |
Record identifier field name. |
|
private |
Record is a new created record flag. |
|
private |
Record dirty attributes map. |
Method Summary
Public Methods | ||
public |
Clear all attributes values with default values. |
|
public |
deserialize(arg_serialized: stirng): boolean Transform attributes string to an object. |
|
public |
Fill all attributes values with given datas. |
|
public |
Get an attribute value. |
|
public |
get_attributes(): Immutable.Map Get record attributes. |
|
public |
Get record attributes. |
|
public |
Get record collection. |
|
public |
get_fields_names(): array Get record fields names. |
|
public |
Get record id. |
|
public |
Get record id field name. |
|
public |
Get record model. |
|
public |
Get record type. |
|
public |
Reload record from collection store. |
|
public |
Delete record from collection store. |
|
public |
Disguard all dirty attributes values. |
|
public |
Save all attributes values to the collection store. |
|
public |
Transform attributes to a string. |
|
public |
Set an attribute value. |
|
public |
set_attributes(arg_attributes: object | Immutable.Map): nothing Set record attributes and normalize with schema. |
|
public |
set_removed(): nothing Set record as removed. |
Private Methods | ||
private |
_check_attribute(arg_attribute_name: string, arg_attribute_value: any): boolean Check attribute name and value against model schema. |
|
private |
Emit on event. |
Public Constructors
public constructor(arg_data_collection: DataCollection, arg_id: string, arg_attributes: object | Immutable.Map): nothing source
Data record class, contains one collection item attributes.
Params:
Name | Type | Attribute | Description |
arg_data_collection | DataCollection | data collection: contains schema. |
|
arg_id | string | data id, unique in collection. |
|
arg_attributes | object | Immutable.Map | initial datas values. |
Return:
nothing |
Public Members
Private Members
Public Methods
public deserialize(arg_serialized: stirng): boolean source
Transform attributes string to an object.
Params:
Name | Type | Attribute | Description |
arg_serialized | stirng | serialized attributes. |
public fill(-: arg_datas): boolean source
Fill all attributes values with given datas.
Params:
Name | Type | Attribute | Description |
- | arg_datas | new attribute values. |
public get(arg_attribute_path: string | array): any | undefined source
Get an attribute value.
Params:
Name | Type | Attribute | Description |
arg_attribute_path | string | array | attribute name or path. |
public get_fields_names(): array source
Get record fields names.
Return:
array | array of all schema fields names strings. |
public set(arg_attribute_path: string | array, arg_attribute_value: any): boolean source
Set an attribute value.
Params:
Name | Type | Attribute | Description |
arg_attribute_path | string | array | attribute name or path. |
|
arg_attribute_value | any | attribute value. |
public set_attributes(arg_attributes: object | Immutable.Map): nothing source
Set record attributes and normalize with schema.
Params:
Name | Type | Attribute | Description |
arg_attributes | object | Immutable.Map | attributes map. |
Return:
nothing |