import { ColumnOptions } from './decorators'; import { EntityMetadataKey, ColumnMetadataKey } from './decorators'; import { Injectable, Type, GET_INGER_DECORATOR, Injector } from "@notadd/core"; @Injectable() export class TypeormHelper { constructor(private injector: Injector) { } getComment(type: Type): { [key: string]: string } { const getNger = this.injector.get(GET_INGER_DECORATOR) const target = getNger(type) const isEntity = target.classes.some(it => it.metadataKey === EntityMetadataKey) const result = {}; if (isEntity) { target.properties.forEach(it => { if (it.metadataKey === ColumnMetadataKey) { const options = it.options as ColumnOptions; if (options) Reflect.set(result, it.property, options.comment || '') } }) } return result; } }