NOTE
StrongLoop Arc is no longer under active development, and will soon be deprecated. Arc's features are being included in the IBM API Connect Developer Toolkit: Please use it instead.
Skip to end of metadata
Go to start of metadata

Prerequisites

Icon
  1. Install StrongLoop.
  2. Follow instructions in Using Arc:
    1. If you don't already have an app, create a LoopBack app with slc loopback.
    2. In the project root directory, start Arc and login: slc arc.

 Contents

Models are at the heart of LoopBack: they encapsulate your application's data and how your application handles the data.  LoopBack models automatically have both a Node API and a REST API; for a model backed by a data source, the APIs provide create, read, update, and delete (CRUD) capabilities.  You can access the REST API during development with the API explorer.  For more information, see Working with data.

The model editor enables you to quickly develop LoopBack models without having to write JSON or code. 


Icon

This release of StrongLoop Composer enables you to quickly get started by creating and editing models and properties. It does not currently provide the ability to add or edit more advanced features such as access controls (ACLs), custom remote methods, relationships between models, and so on. Use slc loopback command-line tool for these features.

Future releases will provide editors for defining and manipulating these advanced properties.

Creating a new model

To create a new model either:

  • Click + Add New Model in the navigation pane.
  • Click + New under MODEL in the toolbox palette.

The model editor opens to edit the new model.  

Icon

You can also create a model using slc loopback:model, the model generator.

Editing a model

To edit an existing model, simply click on it in the Models folder of the navigation pane.  

The model editor opens to edit the selected model.  

You can edit several models at the same time, since each opens in a separate tab.

Model editor

When you create a new model or edit an existing model as described above, you'll see the model editor:

The model editor has three main sections:

Model name in singular form, along with the Save and Migrate Model buttons (see Migrating a model below).

Model details: special properties that apply to the entire model.

Model properties: each model property has individual attributes.

Click + New Property to add a new property to the model.

Model details

Model details apply to the entire model:

  • Plural form of the model - this is automatically set, but you can override it.
  • Base model class - the class on which this model is based, typically either Model or PersistedModel (for models that will be connected to a persistent data source such as a databse). See LoopBack core concepts for an overivew of model inheritance.
  • Datasource - Click in this field to attach a model to one of the data sources defined for the application. By default new models are attached to the "In-Memory" data source.
  • Public - whether the model is exposed over REST API; see API explorer.
  • Strict - determines whether or not the LoopBack enforces the schema defined by the model properties and ignores others added programmatically.  If this is true, then only properties defined in the model are accepted. Use if you want to ensure the model accepts only predefined properties.

Model properties

Each model has one or more properties, each with the following attributes:

  • Name - See Valid names in LoopBack for rules.
  • Type - Property data type: String, Number, and so on; see LoopBack types for more information.
  • Is ID - whether the property is a unique identifier for the model. See ID properties for more information.
  • Required - whether the property is required to have a value.
  • Index - whether the property will be or is already indexed. See Indexes for more information.
  • Comments - Information annotating the property.

Migrating a model

Click the Migrate Model button to create a database table for each model in your application, with a column for each model property.  This is called LoopBack auto-migration.

Icon

To perform auto-migration, the model must be attached to data source that supports auto-migration. Until then, the Migrate Model button will be disabled.

The following data sources support auto-migration:

  • Oracle
  • PostgreSQL
  • MySQL
  • SQL Server

  • MongoDB*

When your application is attached to one of the above data sources, the Migrate Model button will be enabled when you mouse over it.  Click it to start the migration process.

For more information on auto-updating, see Creating a database schema from models.

Icon

MongoDB is a "schema-less" database. Migrating models in MongoDB will only update indexes.  If you change existing properties, existing records within MongoDB will have the old property but new records going forward will have the new definition with the updated property.

  • No labels