strongloop/loopback-boot — pull request #10 by bajtos (2014-06-13 17:42:58+00:00)
Title: [2.0] Rework model configuration

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 (see strongloop/loopback#324).

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.

/to @ritch please review
/cc @raymondfeng @kraman

Note: I have not implemented the topological sort yet, I'll do that in a new pull request once the direction is approved.