UNPKG

ts-db-helper

Version:
84 lines (83 loc) 2.42 kB
import { DbColumn } from './db-column.model'; import { DbHelperModel } from '../db-helper-model.model'; /** * @public * @class DbRelationModel * * @description * This class add relation mapping to the table * * @author Olivier Margarit * @since 0.2 */ export declare class DbRelationModel { private srcModel; private foreignModel; private reverse; /** * @private * @property {Array<DbColumn>} dbColumns list of columns related to other model */ private dbColumns; /** * @public * @property {{new(): DbHelperModel}} sourceModel source of the relation */ readonly sourceModel: { new (): DbHelperModel; }; /** * @public * @property {{new(): DbHelperModel}} targetModel target of the relation */ readonly targetModel: { new (): DbHelperModel; }; /** * @public * @property {Array<DbColumn>} columns columns list of the relation, multiple columns * are needed for composite keys */ readonly columns: DbColumn[]; /** * @public * @property {boolean} isReverse check the relation direction */ readonly isReverse: boolean; /** * @public * @property {string} type the computed relation type @see RelationType */ readonly type: string | null; /** * @public * @property {string} key the relation key, allow defining multiple relations between two * models and reaching only one of its */ key: string | null; /** * @private * @property {string} relationType the relation type @see RelationType */ private relationType; /** * @public * @constructor create db relation model * * @param {{new(): DbHelperModel}} srcModel the source model of the relation from the column owner * @param {{new(): DbHelperModel}} foreignModel the target model of the relation from the column owner * @param {boolean} reverse tag reverse to follow the link reverse from targetted model */ constructor(srcModel: { new (): DbHelperModel; }, foreignModel: { new (): DbHelperModel; }, reverse?: boolean); /** * @public * @method add add column to the relation * * @param {DbColumn} column the column to add */ add(column: DbColumn): void; }