跑数据库出现这个问题:error: Error: Duplicate entry '' for key 'user.PRIMARY'
来源:6-10 使用 TypeORM 定义数据表结构并完成 CRUD(下)

qq_慕瓜9494057
2023-05-14
重新操作,发现只是删除当前数据的id值,并没有删除整条数据
声明:
async del(id:string):Promise<boolean>{
const res = await this.UserRepository.delete(id);
console.log(res);
if(res.affected>0){
return true;
}
return false;
}
使用:
@Get('/del')
async del():Promise<boolean>{
return await this.userService.del('72399cc2-6ebd-48b6-b4cf-dfbe20570430')
}
写回答
1回答
-
黑石
2023-05-14
感觉 Id 没有写进数据库。 欢迎加 qq 群,更快解决你的问题。
012023-06-07
相似问题