-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add createModelFromConfig and configureModel()
Add new API allowing developers to split the model definition and configuration into two steps: 1. Build models from JSON config, export them for re-use: ```js var Customer = loopback.createModelFromConfig({ name: 'Customer', base: 'User', properties: { address: 'string' } }); ``` 2. Attach existing models to a dataSource and a loopback app, modify certain model aspects like relations: ```js loopback.configureModel(Customer, { dataSource: db, relations: { /* ... */ } }); ``` Rework `app.model` to use `loopback.configureModel` under the hood. Here is the new usage: ```js var Customer = require('./models').Customer; app.model(Customer, { dataSource: 'db', relations: { /* ... */ } }); ``` In order to preserve backwards compatibility with loopback 1.x, `app.model(name, config)` calls both `createModelFromConfig` and `configureModel`.
- Loading branch information
Miroslav Bajtoš
committed
Jun 5, 2014
1 parent
93a74f2
commit f844459
Showing
4 changed files
with
267 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.