Page Contents
Important:
Before running this generator, you must create an application using the application generator.
Then you must run the command from the root directory of the application.
The models involved in the relation must also exist before running this generator.
Synopsis
Creates a new model relation in a LoopBack application.
lb relation [options]
With IBM API Connect v5 developer toolkit:
apic loopback:relation [options]
With legacy StrongLoop tools:
$ slc relation [options]
Options
-h, --help
- Print the generator’s options and usage.
--skip-cache
- Do not remember prompt answers. Default is false.
--skip-install
- Do not automatically install dependencies. Default is false.
Interactive Prompts
The tool will prompt you for:
- Name of the model to create the relationship from.
- Relation type:
- Name of the model to create a relationship with.
- Name for the relation (property name).
Important: The name of the relation must be different than a property it references.
- Custom foreign key (optional)
- Whether a “through” model is required. Repy “Y” to create a HasManyThrough relations.
- Name of the “through” model, if appropriate.
Output
Updates the Model definition JSON files for the models involved in the relation.