UNPKG

blow-data-service

Version:

Observable data service for Blow.

32 lines (31 loc) 1.02 kB
'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;