BindModel Class
the main structure
Property Relationships
Create a BindModel object and create a Bind Command object in the addCommmand() method. The generated ‘command[‘identifier’]’ has MetaView with valid, bind, and output attribute values. Ajax communication uses the ‘axios’ module internally.
Class diagram
an inheritance relationship
You can either inherit and extend the BindModel or override the BindModel to customize it.
Class diagram
Components
Properties
Item | Description |
---|---|
baseConfig | Set binding default config |
url | Set binding default config.url |
_tables | Meta-table collection. Manage multiple meta-tables. |
[[52. BindModel Class-B#_columnType|_columnType] | Set item type. |
items | Item collection |
fn | collection of bound model functions. (Internal function + Exposure function) |
command | collection of binding commands |
columns | Collection of columns. Represents the columns of the _baseTable. |
first | The first dynamically generated meta table |
cbFail | Callback function called upon failure in inspection (valid) |
cbError | Callback function called in case of error |
cbBaseBegin | Default callback function before startup. (used without cbBegin callback function) |
cbBaseValid | Default callback function at inspection (valid) (used without cbValid callback function) |
cbBaseBind | Default callback function when bound. (used without cbBind callback function) |
cbBaseResult | Default callback function on the receipt of bind results. (used without cbResult callback function) |
cbBaseOutput | Output Default callback function. (used without cbOutput callback function) |
cbBaseEnd | Default callback function at execution completion. (used without cbEnd callback function) |
preRegister | callback function initially called upon init() call |
PreCheck | callback function that returns boolean on init() call. |
Method
Item | Description | |
---|---|---|
Check Selector (collection?) | Examine the selector | |
getSelector() | Get a list of destination selectors | |
addcommand (name, opt? , baseTable?) | add command | |
setService(svc, chkType) | Set up a service | |
Init() | Perform the initialization operation. Internally call ‘preRegister()’ -> ‘preCheck()’ -> ‘preReady()’ | |
addTable(name) | Register the table | |
addColumn (column, cmds? , views? , bTable?) | Add columns and map them with commands | |
addColumnValue (name, value, cmds? , views? , bTable?) | Add columns and values, add them to the specified table, and register the reference to the column in the value, bind, output MetaView in Bindcommand. | |
setMapping (mapping: collection \ | object, bTable?) | Map columns |
getObject(): object | Gets the current object as a guid type object. (Circular reference is replaced by $ref value.) | |
setObject(obj, origin) | Set the serialization (guid type) object to the current object. (The object is initialized.) | |
equal(target) | Compare the current object with the specified object. | |
getTypes() | Returns the constructors of the current object and all the constructors of the prototype chain to the array. | |
instanceOf(target) | Verify that the current object is an instance of the specified type (with _UNION) |
Events
Item | Description |
---|---|
OnExecute | expecte() pre-execution event |
OnExecuted | expecte() post-execution event |
Detailed description
Key Properties
baseConfig
Set the binding default config.
type baseConfig = object;
url
Set the binding default config.url.
type url = string;
_tables
This is the meta table collection. Manage multiple meta tables.
type _tables = MetaTableCollection;
_columnType
Set the column type.
type _columnType = MetaColumn;
items
It’s an item collection.
type items = PropertyCollection;
fn
A collection of bound model functions. (Internal function + Exposure function)
type fn = PropertyCollection;
command
A collection of binding commands.
type command = PropertyCollection;
cmd
It’s an alias for command.
type cmd = PropertyCollection;
columns
It’s a column collection. Indicates the column in > _baseTable.
type columns = MetaTableColumnCollection;
first
This is the first dynamically generated meta table. Reference value for > _tables[0].
type first = MetaTable;
cbFail
This is the callback function that is called upon failure by valid.
type cbFail = (result: object, column: MetaColumn) => void;
- result : The object containing the result of the examination.
- column : ‘MetaColumn’ object used in the inspection.
cbError
This is the callback function that is called when an error occurs.
type cbError = (msg: string, status: object, response: object) => void;
- msg : Error message.
- status : The object containing status information.
- response —Response object.
cbBaseBegin
Default callback function before startup (used when cbBegin callback function is not present)
type cbBaseBegin = (command: BindCommand) => void;
- command : The current bind command object.
cbBaseValid
Default callback function at valid (used without cbValid callback function)
type cbBaseValid = (valid: MetaView, command: BindCommand) => boolean;
- valid : object ‘MetaView’ to be inspected.
- command : The current bind command object.
- return : A boolean value representing the result of the examination.
cbBaseBind
Default callback function when bound (used without cbBind callback function)
type cbBaseBind = (
bind: MetaView,
command: BindCommand,
config: object
) => void;
- bind : object ‘MetaView’ to bind.
- command : The current bind command object.
- config : This is the setting object.
cbBaseResult
Default callback function when receiving bind results. (Used when cbResult callback function is not available)
type cbBaseResult = (
data: object,
command: BindCommand,
response: object
) => object;
- data : Bind result data object.
- command : The current bind command object.
- response —Response object.
- return —Returns the processed result object.
cbBaseOutput
Output default callback function (used when cbOutput callback function is not present)
type cbBaseOutput = (
outputs: MetaViewCollection,
command: BindCommand,
response: object
) => object;
- outputs : Metabiew collection.
- command : The current bind command object.
- response —Response object.
- return —Returns the processed result object.
cbBaseEnd
Default callback function at execution completion (used when cbEnd callback function is not present)
type cbBaseEnd = (
status: object,
command: BindCommand,
response: object
) => void;
- status : The object containing status information.
- command : The current bind command object.
- response —Response object.
preRegister
This is the callback function that is initially called upon init().
type preRegister = (model: BindModel) => void;
- model : The current bound model object.
preCheck
Callback function that returns boolean on init() call.
type (model: BindModel)=>boolean;
- model : The current bound model object.
- return : A boolean value representing the result of the examination.
preReady
Callback function called when preCheck callback function result is true when invoking > init().
type preReady = (model: BindModel) => void;
- model : The current bound model object.
_baseTable
Define the default entity.
type _baseTable = MetaTable;
_guid
Unique identifier of the object (GUID). Uniquely identifies the object.
type _guid = string;
_type
The generator function of the object, which was used when the object was created.
type _type = Function;
Key Methods
checkSelector()
Examine the selector.
type checkSelector = (collection: BaseColumnCollection) => boolean;
- collection —Column collection to examine.
- return : A boolean value representing the result of the examination.
getSelector()
Obtain a list of destination selectors.
type getSelector = (collection: PropertyCollection) => object[];
- collection : A collection of properties to be examined; the default is items.
- return : An object array representing a list of selectors.
addCommand()
Add a command.
type addCommand = (
name: string,
option: number,
baseTable: MetaTable
) => BindCommand;
- name : The name of the command.
- option : Output option.
- baseTable : (Optional) Default table object.
- return —Added bind command object.
setService()
Set up the service.
type setService = (service: IServiceAjax, passTypeChk: boolean) => void;
- service : service object.
- PassTypeChk : Whether the service object type inspection has passed or not. (Default: false)
init()
Perform the initialization operation. Internally, call ‘preRegister()’ -> ‘preCheck()’ -> ‘preReady()’.
type init = () => void;
addTable()
Register the table.
type addTable = (name: string) => MetaTable;
- name : The name of the table to be registered.
- return : Returns the registered meta table object.
addColumn()
Add columns and map them to commands.
type addColumn = (
column: MetaColumn,
cmds?: string | string[],
views?: string | string[],
bTable?: string | MetaTable
) => void;
- column: column object to be registered. It could be a string or ‘MetaColumn’ object.
- cmds : (Optional) Command to specify the location of the view; it can be a string or an array of strings.
- views —(Optional) Name of the view entity to be added; it can be a string or an array of strings.
- bTable : (Optional) Default table object or table name to be mapped.
addColumnValue()
Add columns and values, add them to the specified table, and register the reference to the column in the value, bind, and output MetaView in the Bindcommand.
type addColumnValue = (
name: string,
value: any,
cmds?: string | string[],
views?: string | string[],
bTable?: string | MetaTable
) => void;
- name : The name of the column.
- value : The value of the column.
- cmds : Command to specify the location of the view; it can be a string or an array of strings.
- views : The name of the view entity to be added; it can be a string or array of strings.
- bTable : (Optional) Default table object or table name to be mapped.
setMapping()
Map columns.
type setMapping = (
mapping: PropertyCollection | object,
baseTable?: string | MetaTable
) => void;
- mapping —Object or collection to map to MetaColumn
- baseTable —(Optional) Default table object or table name to be mapped.
getObject()
Obtain the current object as a guide type object. (Circular references are replaced by $ref values.)
type getObject = (vOpt?: number, owned?: object | Array<object>) => object;
- vOpt : Import option; default is 0.
- opt=0: Reference structure (_guid:Yes, $ref:Yes)
- opt=1: Redundant structure (_guid:Yes, $ref:Yes)
- opt=2 : Non-tidal structure (_guid: No, $ref: No)
- aged : The parent objects that currently own the object. The default is an empty object.
- return —Returns serialized objects.
a.getObject(2) == b.getObject(2)
setObject()
Set the Guid type object to the current object. (The object will be reset.)
type setObject = (oGuid: object, origin?: object) => void;
- oGuid : Object of the guid type to serialize.
- origin : This is the original object that sets the current object. The default is oGuid.
equal()
Compare the current object with the specified object.
type equal = (target: object) => boolean;
- return —Returns whether the two objects are identical.
getTypes()
Returns the creators of the current object and all the creators of the prototype chain to the array.
type getTypes = () => Array<Function>;
- return : Returns the array of generator functions.
const types = obj.getTypes();
console.log(types); // [Function: MetaObject]
instanceOf()
Verify that the current object is an instance of the specified type (including _UNION)
type instanceOf = (target: object | string) => boolean;
- target : The type of object to be checked (object or string).
- return —Returns whether this is an instance of the specified type.
Key Events
onExecute
Events that are called before the command is executed.
type onExecute = (cmd: BindCommand) => void;
- cmd : Command object to be executed.
onExecuted
An event that is called after the command is executed.
type onExecuted = (cmd: BindCommand, result: object) => void;
- cmd : Command object executed.
- result : The result object of the command execution.