DataAdapter
Extends:
DataAdapter class.
Example:
API:
->constructor(arg_database, arg_models_schemas)
->suspend()
->resume()
->add_model_schema(arg_model_schema)
->remove_model_schema(arg_model_name)
->get_model_schema(arg_model_name):TopologyRuntimeModelSchema
->get_collection(arg_model_name):DataCollection
->load_database(arg_topology_database)
->load_model(arg_model_schema)
->unload_model(arg_model_name)
->load_associations()
->new_record(arg_model_name, arg_record_datas, arg_record_id):DataRecord - create a new data record instance, not saved.
->delete_record(arg_model_name, arg_record_id):Promise(boolean) - delete an existing data record.
->update_record(arg_model_name, arg_record_datas, arg_record_id):Promise(DataRecord) - update an existing data record.
->has_record(arg_model_name, arg_record_id):Promise(boolean) - test if a data record exists with an id.
->find_one_record(arg_model_name, arg_record_id):Promise(DataRecord) - find an existing data record with an id.
->find_or_create_record(arg_model_name, arg_record_id):Promise(DataRecord) - find an existing data record with an id.
->find_records(arg_model_name, arg_query):Promise(DataRecordArray) - find existing data records with a query.
->find_all_records(arg_model_name):Promise(DataRecordArray) - find all xisting data records.
PRIVATE:
->_emit(arg_event, arg_datas=undefined):nothing
USAGE ON BROWSER:
see DataStore
Constructor Summary
Public Constructor | ||
public |
constructor(arg_cache_manager: CacheManager, arg_database: TopologyRuntimeDatabase, arg_models_schemas: object): nothing DataAdapter class is responsible to manage one source of records for many model. |
Member Summary
Public Members | ||
public |
Database promise. |
|
public |
Class type flag. |
Private Members | ||
private |
CacheManager instance. |
|
private |
Adapter collections map. |
|
private |
Adapter includes map. |
|
private |
Adapter roles map. |
|
private |
_topology_database: TopologyRuntimeDatabase Topology database instance. |
|
private |
_topology_models_array: array Topology models array. |
|
private |
Topology models map. |
Method Summary
Public Methods | ||
public |
add_model_schema(arg_model_schema: TopologyRuntimeModelSchema): Promise Add a model schema. |
|
public |
create_record(arg_model_name: string, arg_record_datas: object): Promise Create a new data record. |
|
public |
delete_record(arg_model_name: string, arg_record_id: string): Promise Delete an existing data record. |
|
public |
find_all_records(arg_model_name: string): Promise Find all existing data records. |
|
public |
find_one_record(arg_model_name: string, arg_record_id: string): Promise Find an existing data record with an id. |
|
public |
find_or_create_record(arg_model_name: string, arg_record_datas: object, arg_record_id: string): Promise Find an existing data record with an id or create it with given datas. |
|
public |
find_records(arg_model_name: string, arg_query: DataQuery): Promise Find existing data records corresponding to the given query. |
|
public |
get_collection(arg_model_name: string): DataCollection Get a collection for a registered model schema. |
|
public |
get_model_schema(arg_model_name: string): TopologyRuntimeModelSchema Get a registered model schema. |
|
public |
has_record(arg_model_name: string, arg_record_id: string): Promise Test if a data record exists with an id. |
|
public |
Load associations between models. |
|
public |
load_database(arg_topology_database: TopologyRuntimeDatabase): Promise Load adapter topology database. |
|
public |
load_model(arg_model_schema: TopologyRuntimeModelSchema): Promise Load model. |
|
public |
new_record(arg_model_name: string, arg_record_datas: object, arg_record_id: string): Promise Create a new data record instance, not saved. |
|
public |
remove_model_schema(arg_model_name: string): Promise Remove a model schema. |
|
public |
Resume adapter work. |
|
public |
Suspend adapter work. |
|
public |
unload_model(arg_model_name: string): Promise Unload model. |
|
public |
update_record(arg_model_name: string, arg_record_datas: object): Promise Update an existing data record. |
Private Methods | ||
private |
Emit on event. |
Inherited Summary
From class Loggable | ||
public |
Log context. |
|
public |
Class type flag. |
|
public |
Trace is enabled for this flag. |
|
private |
Logger manager instance (default undefined) |
|
public |
Trace DEBUG formatted message. |
|
public |
disable_trace(): nothing Disable traces. |
|
public |
enable_trace(): nothing Enable traces. |
|
public |
enter_group(arg_group: string): nothing Trace INFO message on "enter trace group". |
|
public |
Trace ERROR formatted message. |
|
public |
Define get class name method for non Instance classes. |
|
public |
Get instance context. |
|
public |
Get logger manager. |
|
public |
Define get instance name method for non Instance classes. |
|
public |
Get trace flag. |
|
public |
Trace INFO formatted message. |
|
public |
leave_group(arg_group: string): nothing Trace INFO message on "leave trace group". |
|
public |
separate_level_1(): nothing Trace INFO trace level 1 separator. |
|
public |
separate_level_2(): nothing Trace INFO trace level 2 separator. |
|
public |
separate_level_3(): nothing Trace INFO trace level 3 separator. |
|
public |
Set trace flag. |
|
public |
should_trace(arg_traces_cfg: object): boolean Calculate should trace flag. |
|
public |
should_trace_class(arg_traces_cfg: object): boolean Calculate should trace flag for classes. |
|
public |
should_trace_collection_item(arg_traces_cfg: object, arg_collection_name: string, arg_this_item_accessor: string): boolean Calculate should trace flag for given collection of names or patterns. |
|
public |
should_trace_module(arg_traces_cfg: object): boolean Calculate should trace flag for modules. |
|
public |
should_trace_name(arg_traces_cfg: object): boolean Calculate should trace flag for instances names. |
|
public |
Toggle trace flag. |
|
public |
update_trace_enabled(): nothing Update trace enabled flag. |
|
public |
Trace WARN formatted message. |
Public Constructors
public constructor(arg_cache_manager: CacheManager, arg_database: TopologyRuntimeDatabase, arg_models_schemas: object): nothing source
DataAdapter class is responsible to manage one source of records for many model. DataAdapter instances are managed by a DataStore instance.
Override:
Loggable#constructorParams:
Name | Type | Attribute | Description |
arg_cache_manager | CacheManager | cache manager instance. |
|
arg_database | TopologyRuntimeDatabase | topology database. |
|
arg_models_schemas | object | topology models schemas array. |
Return:
nothing |
Public Members
Private Members
Public Methods
public add_model_schema(arg_model_schema: TopologyRuntimeModelSchema): Promise source
Add a model schema.
Params:
Name | Type | Attribute | Description |
arg_model_schema | TopologyRuntimeModelSchema | topology model schema. |
public create_record(arg_model_name: string, arg_record_datas: object): Promise source
Create a new data record.
public delete_record(arg_model_name: string, arg_record_id: string): Promise source
Delete an existing data record.
public find_all_records(arg_model_name: string): Promise source
Find all existing data records.
Params:
Name | Type | Attribute | Description |
arg_model_name | string | topology model name. |
public find_one_record(arg_model_name: string, arg_record_id: string): Promise source
Find an existing data record with an id.
public find_or_create_record(arg_model_name: string, arg_record_datas: object, arg_record_id: string): Promise source
Find an existing data record with an id or create it with given datas.
public find_records(arg_model_name: string, arg_query: DataQuery): Promise source
Find existing data records corresponding to the given query.
public get_collection(arg_model_name: string): DataCollection source
Get a collection for a registered model schema.
Params:
Name | Type | Attribute | Description |
arg_model_name | string | topology model name. |
public get_model_schema(arg_model_name: string): TopologyRuntimeModelSchema source
Get a registered model schema.
Params:
Name | Type | Attribute | Description |
arg_model_name | string | topology model name. |
Return:
TopologyRuntimeModelSchema | model schema. |
public has_record(arg_model_name: string, arg_record_id: string): Promise source
Test if a data record exists with an id.
public load_database(arg_topology_database: TopologyRuntimeDatabase): Promise source
Load adapter topology database.
Params:
Name | Type | Attribute | Description |
arg_topology_database | TopologyRuntimeDatabase | topology database. |
public load_model(arg_model_schema: TopologyRuntimeModelSchema): Promise source
Load model.
Params:
Name | Type | Attribute | Description |
arg_model_schema | TopologyRuntimeModelSchema | topology model schema. |
public new_record(arg_model_name: string, arg_record_datas: object, arg_record_id: string): Promise source
Create a new data record instance, not saved.
public remove_model_schema(arg_model_name: string): Promise source
Remove a model schema.
Params:
Name | Type | Attribute | Description |
arg_model_name | string | topology model name. |
public unload_model(arg_model_name: string): Promise source
Unload model.
Params:
Name | Type | Attribute | Description |
arg_model_name | string | model name. |
public update_record(arg_model_name: string, arg_record_datas: object): Promise source
Update an existing data record.