all files / src/ DataService.js

26.67% Statements 4/15
0% Branches 0/6
0% Functions 0/4
26.67% Lines 4/15
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 31 32                                                       
'use strict';
const blow_service_1 = require('blow-service');
const connectors = require('./connectors/connectors');
const Collection_1 = require('./Collection');
class DataService extends blow_service_1.Service {
    _getConnector(connectorTypeId) {
        connectorTypeId = connectorTypeId.toLowerCase();
        if (connectorTypeId === 'mongodb') {
            return connectors.MongoDBConnector;
        }
        else if (connectorTypeId === 'memory') {
            return connectors.MemoryConnector;
        }
        throw new Error(`Unrecognized connector type: ${connectorTypeId}`);
    }
    _getConnection(name) {
        if (name) {
            return this.getConnection(name);
        }
        else {
            return this.getDefaultConnection();
        }
    }
    collection(name, connectionName) {
        return new Collection_1.Collection(name, this._getConnection(connectionName));
    }
    static create(settings) {
        return new this(settings);
    }
}
exports.DataService = DataService;