import { Rule } from '@angular-devkit/schematics'; import { ClassRelationEnum, ModelRelation } from '@vmfvmf/ywtc-lib'; import { getModelById, getPrjSrd } from '../../../router.gen'; import { BackEndGenerator } from '../../../shared/generator'; import { underscore } from '@angular-devkit/core/src/utils/strings'; export function gen(rel: ModelRelation): Rule { if (rel.relation !== ClassRelationEnum.ManyToMany) { throw Error("For creating a MxN script is required a parent relation many to many"); } var model = getModelById(rel.modelId); const parentName = underscore(model.name!); const childName = underscore(rel.toModelName); return new BackEndGenerator(__filename).gen({...model, ...getPrjSrd(), parentName, childName}); }