Adds a new model to a LoopBack application.
apic create --type model [options] [<name>]
$ lb model [options] [<name>]
With legacy StrongLoop tools:
slc loopback:model [options] [<name>]
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.
The tool will list all data sources defined in the application’s
datasources.jsonfile. By default, only the Memory connector data source exists. 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.