Page Contents
Tip: Missing instructions for your LoopBack 3 use case? Please report a Migration docs issue on GitHub to let us know.
The command line interfaces of LoopBack 3 and LoopBack 4 have some similarities, but also some differences.
We will outline these similarities and differences below.
Similar Commands
The following commands are similar in nature.
LB3 Commands | LB4 Commands | Description | |
---|---|---|---|
lb or lb app
|
lb4 or lb4 app
|
Create a new application | |
lb datasource
|
lb4 datasource
|
Create a new datasource | |
lb model
|
lb4 model
|
Create a new model. In LB3, this would create the model, but you would automatically get all the model methods and remote methods. In LB4, this command only creates the model; you must also create a repository to handle the CRUD operations of your model, and you must create a controller to define your model's REST API endpoints. Alternatively, you can use lb4 rest-crud to create a configuration file that allows you to avoid having to create a repository and controller.
|
|
lb relation
|
lb4 relation
|
Create a relation between two models | |
lb swagger
|
lb4 openapi
|
In LB3, create a fully functioning application using an API defined in the Swagger 2.0 specification. In LB4, create a fully functioning application using an API defined in either the Swagger 2.0 or the OpenAPI 3.0 specification. |
LoopBack 3 Commands with No Equivalent in LoopBack 4
Commands that are unique to LoopBack 3.
Commands | Description | Workaround in LB4 |
---|---|---|
lb bluemix
|
Create a new application destined in Bluemix | We have several tutorials on how to deploy a LoopBack 4 application to the IBM Cloud: Deploying to Cloud Foundry on IBM Cloud, Deploying to Kubernetes on IBM Cloud, Deploying to Kubernetes on IBM Cloud using Appsody |
lb property
|
Adds properties to an existing model | Open the model file, and manually add a new property. |
lb acl
|
Adds acl settings to models | The access-control-migration example demonstrates how to implement a Role Based Access Control (RBAC) system in LoopBack 4 using the AuthenticationComponent and AuthorizationComponent components. Also, see Migrating authentication and authorization for more details. |
lb remote-method
|
Adds a new remote method to an application | Open the model's controller file, add a new controller method, and decorate the new method with the appropriate rest decorator to define the new REST API endpoint. See Writing controller methods for more details. Depending on the purpose of this new controller method, you may also need to add a new method to the model's repository. |
lb middleware
|
Add new middleware to the application | There is work in progress to enable express middleware in the form of interceptors that you will need to create and register. Also, see Migrating Express middleware for more details. |
lb boot-script
|
Creates a skeleton boot script in server/boot directory. Allows for customized intialization of anything during boot phase | Create a lifecycle observer to run custom code during different phases of the application's lifecycle; including startup. See Migrating boot scripts for more details. |
lb export-api-def
|
Export the application's API definitions to a YAML or JSON file | Visit the application's /openapi.json endpoint to access your OpenAPI specification in JSON format, or the /openapi.yaml endpoint for YAML. Alternatively, the OpenAPI specification file can also be accessed in code through the getApiSpec() function from your RestServer instance. Read Reviewing your API Specification for more details. |
lb soap
|
Create a SOAP client based on a SOAP service's WSDL file | See Calling other APIs and web services for the simple steps required to connect to a SOAP service. |
LoopBack 4 Commands with No Equivalent in LoopBack 3
Commands that are unique to LoopBack 4.
Commands | Description | Reason for difference from LB3 |
---|---|---|
lb4 repository
|
Create a repository for a model | A new concept in LB4. A model's repository> defines the CRUD operations. In LB3, the model defined the CRUD operations. |
lb4 controller
|
Create a controller for a model | A new concept in LB4. A model's controller defines its REST API endpoints. In LB3, the model's remote methods defined the REST API endpoints. |
lb4 import-lb3-models
|
Import models from an LB3 project into LB4 | A new utility command in LB4. |
lb4 rest-crud
|
Use this command against a model and datasource, and it creates a rest-crud configuration that allows you to avoid creating a repository and controller for the model | A new utility command in LB4. In LB3, the model defined the CRUD operations and REST API endpoints; there was no need for a command like this. In fact, this LB4 command's purpose allows a user to avoid defining a repository and controller for a given model; similar to the user effort in LB3. |
lb4 service
|
Create a service | A new concept in LB4. See Services for more details. |
lb4 discover
|
Create models based on table definitions of database backends | A new utility command in LB4. In LB3, discovery was performed programmatically. |
lb4 observer
|
Create a lifecycle observer | A new concept in LB4. See Life cycle events and observers for more details. |
lb4 interceptor
|
Create an interceptor | A new concept in LB4. See Interceptors for more details. |
lb4 extension
|
Create a new extension | A new utility command in LB4. LB3 modules are stored in separate github repositories whereas LB4 modules are stored in a single repository (a monorepo). This LB4 command allows a contributor to easily add a new extension subdirectory to the monorepo. |
lb4 update
|
Update Loopback 4 project dependencies | A new utility command in LB4. |
lb4 copyright
|
Add/Update Copyright headers in source code files | A new utility command in LB4. |
lb4 example
|
Download LoopBack 4 examples | A new utility command in LB4. |