Overview
The file /server/model-config.json
configures LoopBack models, for example it binds models to data sources and specifies whether a model is exposed over REST. The models referenced in this file must be either a built-in models or custom models defined by a JSON file in the common/models/
folder.
For example, here is the default model-config.json
that lists all the built-in models:
model-config.json
{ "_meta": { "sources": [ "../common/models", "./models" ] }, "User": { "dataSource": "db" }, "AccessToken": { "dataSource": "db", "public": false }, "ACL": { "dataSource": "db", "public": false }, "RoleMapping": { "dataSource": "db", "public": false }, "Role": { "dataSource": "db", "public": false } }
Model configuration properties
Property | Type | Description |
---|---|---|
_meta.sources | Array | Array of relative paths to custom model definitions. |
model-name.datasource | String | Name of data source to which the model is connected |
model-name.public | Boolean | If true, then the model is exposed over REST. Does not affect accessibility of Node API. |
_meta.sources
By default, LoopBack applications load models from /common/models
subdirectory. To specify a different location (or even multiple locations) use the _meta.sources
property, whose value is an array of directory paths.