docs/site/Model-generator.md
{% include content/generator-create-app.html lang=page.lang %}
Adds a new Model class to a LoopBack application.
lb4 model [options] [<name>]
--base : (Optional) a valid model already created in src/models or any of
the core based class models Entity or Model. Your new model will extend this
selected base model class.
{% include_relative includes/CLI-std-options.md %}
<name> - Required name of the model to create as an argument to the command.
If provided, the tool will use that as the default when it prompts for the name.
The tool will prompt you for:
Name of the model. (modelName) If the name had been supplied from the command line, the prompt is skipped and the datasource is built with the name from the command-line argument.
Model base class. (modelBaseClass) If the command line option --base had
been supplied with a valid model class name, the prompt is skipped. It will
present you with a list of available models from src/models including the
Entity and Model at the top of the list.
Allow additional properties. (allowAdditionalProperties) Defaults to false. To allow arbitrary properties in addition to well-defined properties, disable strict mode.
The tool will next recursively prompt you for the model's properties until a blank one is entered. Properties will be prompted for as follows:
string, number, boolean, object, array, date, buffer,
geopoint, any.id for the Model.Once all the prompts have been answered, the CLI will do the following:
/src/models/${modelName}.model.ts/src/models/index.ts to export the newly created Model class.