Models are at the heart of LoopBack, and represent back-end data sources such as databases or other back-end services (REST, SOAP, and so on).
Prerequisite: Install command-line tools as described in Installation.
Recommended: Read LoopBack core concepts.
Page Contents
A LoopBack model represents data in backend systems such as databases, and by default has both Node and REST APIs. Additionally, you can add functionality such as validation rules and business logic to models.
Every LoopBack application has a set of predefined built-in models such as User, Role, and Application. You can extend built-in models to suit your application’s needs.
Additionally, you can define your own custom models specific to your application:
- Use the model generator to create custom models from scratch. This creates a Model definition JSON file that defines your model in LoopBack.
- Use
Datasource.buildModelFromInstance()
to create dynamic schema-less models for data sources such as SOAP and REST services. See Creating models from unstructured data for more information. - For data sources backed by a relational database, a model typically corresponds to a table. Use model discovery to create static, schema-driven models for database-backed data sources. See Discovering models from relational databases for more information.