Some LoopBack connectors require
that the data model to be interacted with is defined through a LoopBack JSON model. When the
LoopBackRequest node interacts
for the first time with a named LoopBack object,
which is either specified as a node property or dynamically overridden
in the local environment, it looks for a LoopBack JSON model file in a subdirectory
of the directory that contains the
datasources.json file.
This subdirectory, which you must create, must have exactly the same
name and case as the data-source stanza that is specified on the
LoopBackRequest node. For example,
if the
datasources.json file is provided only
at the node location, the model would be:
workpath/connectors/loopback/datasource_name/model_name.json
The
model_name part
of the
model_name.json file
must match exactly (including the case) the
LoopBack object name
that is either specified on the
LoopBackRequest node or overridden
with the
LocalEnvironment.Destination.Loopback.Request.object local
environment variable.
The name that is specified in the LoopBack
object property of the LoopBackRequest node is the
base name of the model file (excluding the .json file
extension), and the name property in the model
file defines the LoopBack object
that will be interacted with. Typically, these names are the same,
but they can be different; for example, if the name of the object
in the LoopBack connected
system contains a character that would be invalid in a file name.
If the names are different, a BIP3880 message is issued.
The
following example shows how you could provide LoopBack JSON model files for working with
the dev
and staging
MongoDB data
sources:
<workpath>
\---connectors
\---loopback
+---datasources.json
|
+---mongodb_dev
| +---customer.json
| +---order.json
| \---test.json
|
\---mongodb_stage
+---customer.json
\---order.json
For more information about
using models, see
Using models with LoopBack connectors.