strongloop/loopback — pull request #304 by bajtos (2014-06-05 15:50:29+00:00)
Title: 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`.

See strongloop/loopback-example-full-stack#13 for background of this change.

/to @ritch @raymondfeng please review