typeorm#AfterLoad TypeScript Examples

The following examples show how to use typeorm#AfterLoad. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckResultEntity.ts    From context-mod with MIT License 6 votes vote down vote up
@AfterLoad()
    sortRuns() {
        if (this.ruleResults !== undefined) {
            this.ruleResults.sort((a, z) => a.order - z.order);
        }
        if (this.ruleSetResults !== undefined) {
            this.ruleSetResults.sort((a, z) => a.order - z.order);
        }
        if (this.actionResults !== undefined) {
            this.actionResults.sort((a, b) => a.createdAt.isSameOrBefore(b.createdAt) ? -1 : 1);
        }
    }
Example #2
Source File: DispatchedEntity.ts    From context-mod with MIT License 6 votes vote down vote up
@AfterLoad()
    convertPrimitives() {
        if (this.cancelIfQueued !== undefined) {
            const cVal = this.cancelIfQueued as string;
            if (cVal === 'true') {
                this.cancelIfQueued = true;
            } else if (cVal === 'false') {
                this.cancelIfQueued = false;
            } else if (cVal.includes('[')) {
                this.cancelIfQueued = JSON.parse(cVal) as NonDispatchActivitySource[];
            }
        }
        if(this.goto === null) {
            this.goto = undefined;
        }
        if(this.action === null) {
            this.action = undefined;
        }
        if(this.identifier === null) {
            this.identifier = undefined;
        }
        if(this.cancelIfQueued === null) {
            this.cancelIfQueued = undefined;
        }
        if(this.onExistingFound === null) {
            this.onExistingFound = undefined;
        }
        if(this.dryRun === null) {
            this.dryRun = undefined;
        }
    }
Example #3
Source File: user.entity.ts    From office-hours with GNU General Public License v3.0 6 votes vote down vote up
@AfterLoad()
  computeInsights(): void {
    let hideInsights = this.hideInsights;
    if (!hideInsights) {
      hideInsights = [];
    }
    const insightNames = Object.keys(INSIGHTS_MAP);
    this.insights = insightNames.filter((name) => !hideInsights.includes(name));
  }
Example #4
Source File: CMEvent.ts    From context-mod with MIT License 5 votes vote down vote up
@AfterLoad()
    sortRuns() {
        if(this.runResults !== undefined) {
            this.runResults.sort((a, b) => a.createdAt.isSameOrBefore(b.createdAt) ?  -1 : 1);
        }
    }
Example #5
Source File: RuleSetResultEntity.ts    From context-mod with MIT License 5 votes vote down vote up
@AfterLoad()
    sortRuns() {
        if(this._ruleResults !== undefined) {
            this._ruleResults.sort((a, z) => a.order - z.order);
        }
    }
Example #6
Source File: RunResultEntity.ts    From context-mod with MIT License 5 votes vote down vote up
@AfterLoad()
    sortRuns() {
        this.checkResults.sort((a, b) => a.createdAt.isSameOrBefore(b.createdAt) ?  -1 : 1);
    }
Example #7
Source File: CashAction.ts    From cashcash-desktop with MIT License 5 votes vote down vote up
@AfterLoad()
    updateRandomId() {
        if (this.jsonActionList) {
            this.jsonActionList.forEach((item) => (item.randomId = Math.random()));
        }
    }
Example #8
Source File: CashFilter.ts    From cashcash-desktop with MIT License 5 votes vote down vote up
@AfterLoad()
    updateRandomId() {
        if (this.jsonFilter) {
            this.jsonFilter.list.forEach((item) => (item.randomId = Math.random()));
        }
    }
Example #9
Source File: CashImportConfig.ts    From cashcash-desktop with MIT License 5 votes vote down vote up
@AfterLoad()
    initializeObject() {
        const defaultImportConfig: CashImportConfigDetails = _.cloneDeep(DEFAULT_IMPORT_CONFIG);

        if (this.jsonConfig && this.jsonConfig.parsing && this.jsonConfig.parsing.type) {
            this.type = this.jsonConfig.parsing.type;
        } else {
            this.type = CashImportType.SPREADSHEET;
        }
        if (!this.jsonConfig.converting) {
            this.jsonConfig.converting = defaultImportConfig.converting;
        }
        if (!this.jsonConfig.converting.property.description) {
            this.jsonConfig.converting.property.description =
                defaultImportConfig.converting.property.description;
        }
        if (!this.jsonConfig.converting.property.detail) {
            this.jsonConfig.converting.property.detail =
                defaultImportConfig.converting.property.detail;
        }
        if (!this.jsonConfig.converting.property.transactionDate) {
            this.jsonConfig.converting.property.transactionDate =
                defaultImportConfig.converting.property.transactionDate;
        }
        if (!this.jsonConfig.converting.property.amount) {
            this.jsonConfig.converting.property.amount =
                defaultImportConfig.converting.property.amount;
        }
        if (!this.jsonConfig.converting.property.currency) {
            this.jsonConfig.converting.property.currency =
                defaultImportConfig.converting.property.currency;
        }
        if (!this.jsonConfig.converting.property.currency.mode) {
            // We fix old version without mode
            (this.jsonConfig.converting.property.currency as any).mode =
                CashImportCurrencyMode.READ;
        }
        if (
            this.jsonConfig.converting.property.description &&
            this.jsonConfig.converting.property.description.extra
        ) {
            this.jsonConfig.converting.property.description.extra.forEach(
                (item) => (item.randomId = Math.random()),
            );
        }
        if (
            this.jsonConfig.converting.property.detail &&
            this.jsonConfig.converting.property.detail.extra
        ) {
            this.jsonConfig.converting.property.detail.extra.forEach(
                (item) => (item.randomId = Math.random()),
            );
        }
        if (!this.jsonConfig.extra) {
            this.jsonConfig.extra = {};
        }
    }
Example #10
Source File: user.entity.ts    From office-hours with GNU General Public License v3.0 5 votes vote down vote up
@AfterLoad()
  setFullNames(): void {
    this.name = this.firstName + ' ' + this.lastName;
  }