UNPKG

graph-common

Version:
53 lines (42 loc) 1.62 kB
(function() { var Query, StorageManager, __slice = [].slice; Query = require('./query'); StorageManager = (function() { function StorageManager(graph, configuration_uri) { this.graph = graph; this.configuration = { uri: configuration_uri }; this.parse_configuration_uri(configuration_uri); this.load_driver(); this.instantiate_database(); } StorageManager.prototype.parse_configuration_uri = function(configuration_uri) { var database, driver, host, rest, _ref, _ref1; _ref = configuration_uri.split('://'), driver = _ref[0], rest = _ref[1]; _ref1 = rest.split('/'), host = _ref1[0], database = _ref1[1]; this.configuration.driver = driver; this.configuration.host = host; return this.configuration.database = database; }; StorageManager.prototype.load_driver = function() { return this.driver = require('./' + this.configuration.driver + '_storage'); }; StorageManager.prototype.instantiate_database = function() { return this.db = this.database = new this.driver(this.configuration.uri); }; StorageManager.prototype.__noSuchMethod__ = function() { var args, method, _ref; method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; if (this.driver) { if (!this.database) { this.instantiate_database(); } return (_ref = this.database.method).apply.apply(_ref, [null].concat(__slice.call(args))); } }; return StorageManager; })(); module.exports = StorageManager; }).call(this);