Add app.dataSource() method

This commit is contained in:
Ritchie 2013-10-31 10:06:43 -07:00
parent da5cb2c117
commit 6179476030
2 changed files with 12 additions and 4 deletions

View File

@ -29,7 +29,7 @@ Initialize an application from an options object or a set of JSON and JavaScript
1. **DataSources** are created from an `options.dataSources` object or `datasources.json` in the current directory
2. **Models** are created from an `options.models` object or `models.json` in the current directory
3. Any JavaScript files in the `./models` and `./datasources` directories are required.
3. Any JavaScript files in the `./models` directory are loaded with `require()`.
**Options**

View File

@ -84,6 +84,16 @@ app.models = function () {
return this._models;
}
/**
* Define a DataSource.
*/
app.dataSource = function (name, config) {
this.dataSources[name] =
this.dataSources[classify(name)] =
this.dataSources[camelize(name)] = dataSourcesFromConfig(config);
}
/**
* Get all remote objects.
*/
@ -185,9 +195,7 @@ app.boot = function(options) {
// instantiate data sources
forEachKeyedObject(dataSourceConfig, function(key, obj) {
app.dataSources[key] =
app.dataSources[classify(key)] =
app.dataSources[camelize(key)] = dataSourcesFromConfig(obj);
app.dataSource(key, obj);
});
// instantiate models