UNPKG

@jschmold/kor

Version:

`npm i mocha ts-node typedoc typescript --global`

25 lines (24 loc) 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _1 = require("."); function Model(name) { return function (constructor) { var proto = constructor.prototype; proto._dataSourceName = name; }; } exports.Model = Model; function bindModel(arg) { var proto = arg.prototype || arg.constructor.prototype; var name = proto._dataSourceName; if (name == null) throw new Error('Bind model called on ${arg.name} that has no _dataSourceName'); var src = _1.Kor.getConnectionDetails(name); if (src == null) throw new Error('Unable to bind model to nonexistent data source'); src.entities != null ? src.entities.push(arg) : [arg]; console.debug("Bound new model " + arg.name + " to " + name); } exports.bindModel = bindModel;