UNPKG

@rytass/cms-base-nestjs-module

Version:

Rytass Content Management System NestJS Base Module

83 lines (80 loc) 2.92 kB
import { PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToMany, JoinTable, OneToMany, Entity, TableInheritance } from 'typeorm'; import { BaseCategoryMultiLanguageNameEntity } from './base-category-multi-language-name.entity.js'; import { BaseArticleEntity } from './base-article.entity.js'; function _ts_decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } const BaseCategoryRepo = Symbol('BaseCategoryRepo'); class BaseCategoryEntity { id; bindable; createdAt; updatedAt; deletedAt; parents; children; multiLanguageNames; articles; } _ts_decorate([ PrimaryGeneratedColumn('uuid') ], BaseCategoryEntity.prototype, "id", void 0); _ts_decorate([ Column('boolean', { default: false, comment: 'is article bindable' }) ], BaseCategoryEntity.prototype, "bindable", void 0); _ts_decorate([ CreateDateColumn('timestamptz') ], BaseCategoryEntity.prototype, "createdAt", void 0); _ts_decorate([ UpdateDateColumn('timestamptz') ], BaseCategoryEntity.prototype, "updatedAt", void 0); _ts_decorate([ DeleteDateColumn('timestamptz') ], BaseCategoryEntity.prototype, "deletedAt", void 0); _ts_decorate([ ManyToMany(()=>BaseCategoryEntity, (category)=>category.children), JoinTable({ name: 'category_relations', joinColumn: { name: 'childId', referencedColumnName: 'id' }, inverseJoinColumn: { name: 'parentId', referencedColumnName: 'id' } }) ], BaseCategoryEntity.prototype, "parents", void 0); _ts_decorate([ ManyToMany(()=>BaseCategoryEntity, (category)=>category.parents, { onUpdate: 'CASCADE', onDelete: 'CASCADE', orphanedRowAction: 'delete' }) ], BaseCategoryEntity.prototype, "children", void 0); _ts_decorate([ OneToMany(()=>BaseCategoryMultiLanguageNameEntity, (multiLanguageName)=>multiLanguageName.category) ], BaseCategoryEntity.prototype, "multiLanguageNames", void 0); _ts_decorate([ ManyToMany(()=>BaseArticleEntity, (article)=>article.categories, { onUpdate: 'CASCADE', onDelete: 'CASCADE', orphanedRowAction: 'delete' }) ], BaseCategoryEntity.prototype, "articles", void 0); BaseCategoryEntity = _ts_decorate([ Entity('categories'), TableInheritance({ column: { type: 'varchar', name: 'entityName' } }) ], BaseCategoryEntity); export { BaseCategoryEntity, BaseCategoryRepo };