forked from gendigbadig/loopback-component-storage-gridfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 800 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var GridFSService = require('./lib/gridfs-service');
/**
* Initialize storage component.
*/
exports.initialize = function(dataSource, callback) {
var settings = dataSource.settings || {};
var connector = new GridFSService(settings);
dataSource.connector = connector;
dataSource.connector.dataSource = dataSource;
connector.DataAccessObject = function () {};
for (var m in GridFSService.prototype) {
var method = GridFSService.prototype[m];
if (typeof method === 'function') {
connector.DataAccessObject[m] = method.bind(connector);
for (var k in method) {
connector.DataAccessObject[m][k] = method[k];
}
}
}
connector.define = function(model, properties, settings) {};
if (callback) {
dataSource.connector.connect(callback);
}
};