Adds a new model to a LoopBack application.
lb model [options] [<name>]
With IBM API Connect developer toolkit:
apic create --type model [options] [--name <name>]
With legacy StrongLoop tools:
slc model [options] [<name>]
- Lists only Bluemix data sources in the datasource option for the new model.
- Print the generator’s options and usage.
- Do not remember prompt answers. Default is false.
- Do not automatically install dependencies. Default is false.
<name> - Optional 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. If you supplied a name on the command-line, just hit Enter to use it.
- Data source to which to attach the model.
If you run the generator without the
--bluemixoption, the tool will list all data sources defined in the application’s
datasources.jsonfile. By default, only the Memory connector data source exists. If you run the generator with the
--bluemixoption, you will be prompted to select a Bluemix datasource. If no Bluemix datasource was added, the generator will exit with an error message. Add additional data sources using the Data source generator.
- Whether you want to expose the model over a REST API. If the model is exposed over REST, then all the standard create, read, update, and delete (CRUD) operations are available via REST endpoints. See PersistedModel REST API for more information. You can also add your own custom remote methods that can be called via REST operations; see Remote methods.
- If you choose to expose the model over REST, the custom plural form of the model.
By default, the LoopBack uses the standard English plural of the word.
The plural form is used in the REST API; for example
- Whether you want to create the model on the server only or for both server and client LoopBack APIs (see LoopBack in the client for more information on the LoopBack client API).
Then, the tool will invoke the Property generator and prompt you to enter model properties
Depending your response to the last prompt, the tool will create a new file defining the model; either
/common/models/model-name.json (for use by client and server) or
/server/models/model-name.json (server only). See Model definition JSON file for details.