Add app.dataSource() method
This commit is contained in:
parent
da5cb2c117
commit
6179476030
|
@ -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**
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue