Updated JSdoc for Datasource constructor

This commit is contained in:
crandmck 2015-05-14 15:53:34 -07:00
parent 82ea32f319
commit d19001a56e
1 changed files with 21 additions and 15 deletions

View File

@ -33,11 +33,10 @@ var slice = Array.prototype.slice;
/** /**
* LoopBack models can manipulate data via the DataSource object. * LoopBack models can manipulate data via the DataSource object.
* Attaching a `DataSource` to a `Model` adds instance methods and static methods to the `Model`; * Attaching a `DataSource` to a `Model` adds instance methods and static methods to the `Model`.
* some of the added methods may be remote methods.
* *
* Define a data source for persisting models. * Define a data source to persist model data.
* Typically, you create a DataSource by calling createDataSource() on the LoopBack object; for example: * To create a DataSource programmatically, call `createDataSource()` on the LoopBack object; for example:
* ```js * ```js
* var oracle = loopback.createDataSource({ * var oracle = loopback.createDataSource({
* connector: 'oracle', * connector: 'oracle',
@ -49,15 +48,10 @@ var slice = Array.prototype.slice;
* ``` * ```
* *
* All classes in single dataSource share same the connector type and * All classes in single dataSource share same the connector type and
* one database connection. The `settings` argument is an object that can have the following properties: * one database connection.
* - host *
* - port * For example, the following creates a DataSource, and waits for a connection callback.
* - username
* - password
* - database
* - debug (Boolean, default is false)
* *
* @desc For example, the following creates a DataSource, and waits for a connection callback.
* ``` * ```
* var dataSource = new DataSource('mysql', { database: 'myapp_test' }); * var dataSource = new DataSource('mysql', { database: 'myapp_test' });
* dataSource.define(...); * dataSource.define(...);
@ -66,8 +60,21 @@ var slice = Array.prototype.slice;
* }); * });
* ``` * ```
* @class DataSource * @class DataSource
* @param {String} name Type of dataSource connector (mysql, mongoose, oracle, redis) * @param {String} [name] Optional name for datasource.
* @param {Object} settings Database-specific settings to establish connection (settings depend on specific connector). See above. * @options {Object} settings Database-specific settings to establish connection (settings depend on specific connector).
* The table below lists a typical set for a relational database.
* @property {String} connector Database connector to use. For any supported connector, can be any of:
*
* - The connector module from `require(connectorName)`.
* - The full name of the connector module, such as 'loopback-connector-oracle'.
* - The short name of the connector module, such as 'oracle'.
* - A local module under `./connectors/` folder.
* @property {String} host Database server host name.
* @property {String} port Database server port number.
* @property {String} username Database user name.
* @property {String} password Database password.
* @property {String} database Name of the database to use.
* @property {Boolean} debug Display debugging information. Default is false.
*/ */
function DataSource(name, settings, modelBuilder) { function DataSource(name, settings, modelBuilder) {
if (!(this instanceof DataSource)) { if (!(this instanceof DataSource)) {
@ -2097,4 +2104,3 @@ DataSource.Any = ModelBuilder.Any;
DataSource.registerType = function (type) { DataSource.registerType = function (type) {
ModelBuilder.registerType(type); ModelBuilder.registerType(type);
}; };