2016-05-03 23:18:18 +00:00
|
|
|
// Copyright IBM Corp. 2013,2014. All Rights Reserved.
|
|
|
|
// Node module: loopback-component-storage
|
|
|
|
// This file is licensed under the Artistic License 2.0.
|
|
|
|
// License text available at https://opensource.org/licenses/Artistic-2.0
|
2016-10-18 22:48:59 +00:00
|
|
|
'use strict';
|
2016-05-03 23:18:18 +00:00
|
|
|
|
2014-01-10 19:34:37 +00:00
|
|
|
var StorageService = require('./storage-service');
|
2013-07-03 23:58:20 +00:00
|
|
|
/**
|
2014-04-08 01:19:35 +00:00
|
|
|
* Initialize the storage service as a connector for LoopBack data sources
|
|
|
|
* @param {DataSource} dataSource DataSource instance
|
|
|
|
* @prop {Object} settings Connector settings
|
|
|
|
* @callback {Function} callback Callback function
|
|
|
|
* @param {String|Object} err Error string or object
|
2013-07-03 23:58:20 +00:00
|
|
|
*/
|
2016-10-18 22:06:55 +00:00
|
|
|
exports.initialize = function(dataSource, callback) {
|
2014-01-24 17:44:58 +00:00
|
|
|
var settings = dataSource.settings || {};
|
2013-07-03 23:58:20 +00:00
|
|
|
|
2014-01-24 17:44:58 +00:00
|
|
|
var connector = new StorageService(settings);
|
|
|
|
dataSource.connector = connector;
|
|
|
|
dataSource.connector.dataSource = dataSource;
|
2013-07-03 23:58:20 +00:00
|
|
|
|
2016-10-18 22:06:55 +00:00
|
|
|
connector.DataAccessObject = function() {
|
2014-01-24 17:44:58 +00:00
|
|
|
};
|
|
|
|
for (var m in StorageService.prototype) {
|
|
|
|
var method = StorageService.prototype[m];
|
|
|
|
if ('function' === typeof method) {
|
|
|
|
connector.DataAccessObject[m] = method.bind(connector);
|
|
|
|
for (var k in method) {
|
|
|
|
connector.DataAccessObject[m][k] = method[k];
|
|
|
|
}
|
2013-07-03 23:58:20 +00:00
|
|
|
}
|
2014-01-24 17:44:58 +00:00
|
|
|
}
|
2013-07-03 23:58:20 +00:00
|
|
|
|
2016-10-18 22:06:55 +00:00
|
|
|
connector.define = function(model, properties, settings) {
|
2014-01-24 17:44:58 +00:00
|
|
|
};
|
2014-01-10 19:34:37 +00:00
|
|
|
};
|