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:
parent
48b045c4f9
commit
c8fa534a77
@ -47,10 +47,11 @@ export async function referentialIntegrityCheck(options: ReferentialIntegrityChe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (onDelete === 'RESTRICT') {
|
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(
|
const error = new Error(
|
||||||
`此数据被 ${
|
`这条无法删除,还有存在的使用它的数据,这条数据为
|
||||||
sourceCollection.options.title || sourceCollectionName
|
${sourceCollection.options.title || sourceCollectionName} 的:${transData}`,
|
||||||
} 表关联,关联字段(as):${sourceField},不能删除!`,
|
|
||||||
);
|
);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user