space-lb2

messaging

space-node

This documentation is deprecated
Please see the new LoopBack documentation site.
Skip to end of metadata
Go to start of metadata

Icon

Before running this generator, you must create an application using slc loopback, the application generator.

Then you must run the command from the root directory of the application.

SYNOPSIS

Adds a new model to a LoopBack application.

slc loopback:model [options] [<name>]

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.

ARGUMENTS

You can optionally provide the name of the model to create as an argument to the command.  If you do, the tool will use that as the default when it prompts for the name.

INTERACTIVE PROMPTS

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.json file. 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 http://localhost:3000/api/locations.
  • 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

OUTPUT

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.