a204fdc1c9
Rework the way how models are configured, the goal is to allow loopback-boot to automatically determine the correct order of the model definitions to ensure base models are defined before they are extended. 1. The model .js file no longer creates the model, it exports a config function instead: ```js module.exports = function(Car, Base) { // Car is the model constructor // Base is the parent model (e.g. loopback.PersistedModel) Car.prototype.honk = function(duration, cb) { // make some noise for `duration` seconds cb(); }; }; ``` 2. The model is created by loopback-boot from model .json file. The .js file must have the same base file name. 3. The `boot()` function has a new parameter `modelSources` to specify the list of directories where to look for model definitions. The parameter defaults to `['./models']`. As a side effect, only models configured in `models.json` and their base clases are defined. This should keep the size of the browserified bundle small, because unused models are not included. |
||
---|---|---|
.. | ||
browser-app | ||
simple-app |