Class: ModelTraverse

ModelTraverse

A class that has helper methods for traversing a database model.

Constructor

new ModelTraverse()

Source:

Methods

breadthFirst(model, callback, database) → {void}

Traverse model (either an object or an array) using a breadth-first traversal.
Parameters:
Name Type Description
model Object | Array.<object> The object or array to traverse.
callback ModelTraverse~modelMetaCallback A function that shall be invoked with for each sub-model within model.
database Database An optional Database instance. If passed, the callback will only be called if a key in the model corresponds to a table mapping.
Source:
Returns:
Type
void

depthFirst(model, callback, database) → {void}

Traverse model (either an object or an array) using a depth-first traversal.
Parameters:
Name Type Description
model Object | Array.<object> The object or array to traverse.
callback ModelTraverse~modelMetaCallback A function that shall be invoked with for each sub-model within model.
database Database An optional Database instance. If passed, the callback will only be called if a key in the model corresponds to a table mapping.
Source:
Returns:
Type
void

modelOnly(model, callback, database) → {void}

Traverse the keys in model.
Parameters:
Name Type Description
model Object | Array.<object> The object or array to traverse.
callback ModelTraverse~modelMetaCallback A function that shall be invoked with for each sub-model within model.
database Database An optional Database instance. If passed, the callback will only be called if a key in the model corresponds to a table mapping.
Source:
Returns:
Type
void

Type Definitions

ModelMeta

Type:
  • Object
Properties:
Name Type Description
tableMapping string The mapping (mapTo) of the table with which the model is associated.
model Object The model itself.
parent Object The model's parent, or null if the model has no parent.
Source:

modelMetaCallback(meta)

A callback prototype that is called upon each iteration of a model.
Parameters:
Name Type Description
meta ModelTraverse~ModelMeta A ModelTraverse~ModelMeta instance describing the current model.
Source: