feat: 优化删除提示,找到对应关联数据 (#543)

Reviewed-on: daoyoucloud/tachycode#543
Co-authored-by: hello@lv <2256334253@qq.com>
Co-committed-by: hello@lv <2256334253@qq.com>
This commit is contained in:
hello@lv 2024-03-30 02:23:07 +08:00 committed by sealday
parent 48b045c4f9
commit c8fa534a77

View File

@ -47,10 +47,11 @@ export async function referentialIntegrityCheck(options: ReferentialIntegrityChe
}
if (onDelete === 'RESTRICT') {
const data = await sourceRepository.find({ filter });
const transData = data.map((item) => `id:${item.id} 数据:${item[sourceCollection.options.titleField]}`).join(',');
const error = new Error(
`此数据被 ${
sourceCollection.options.title || sourceCollectionName
} (as)${sourceField}`,
`这条无法删除,还有存在的使用它的数据,这条数据为
${sourceCollection.options.title || sourceCollectionName} ${transData}`,
);
throw error;
}