UNPKG

@sqb/connect

Version:

Multi-dialect database connection framework written with TypeScript

21 lines (20 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Index = Index; const entity_metadata_js_1 = require("../model/entity-metadata.js"); function Index(arg0, arg1) { return function (target, propertyKey) { if (typeof target === 'function') { if (!(typeof arg0 === 'string' || Array.isArray(arg0))) throw new Error(`You must specify index column(s)`); const model = entity_metadata_js_1.EntityMetadata.define(target); return entity_metadata_js_1.EntityMetadata.addIndex(model, { ...arg1, columns: arg0 }); } if (!target.constructor) throw new Error('Property decorators can be used for class properties only'); if (typeof propertyKey !== 'string') throw new Error('Index() decorator can be used for string property keys only'); const model = entity_metadata_js_1.EntityMetadata.define(target.constructor); entity_metadata_js_1.EntityMetadata.addIndex(model, { ...arg0, columns: [propertyKey] }); }; }