我正在使用Sequelize,GraphQL和Typescript来编写代码 . 我有两个表RecordInformation和OtherDescription . RecordInformation在OtherDescription表上有一个外键“OtherID” .
我的解析器文件中有两个代码 . 我可以在sequelize中使用cascade选项删除记录 .
但是,我想知道如何根据成功执行的每个操作更改此代码以返回true或false值 . 目前, Map 操作的返回类型是Bluebird <number> [] . 我想在删除变异后返回布尔值 .
interface IRecordInformation {
id: number;
RecordID: number;
LabelOptionID: number;
OtherID: number;
}
interface IListRecordInformation {
RecordInformationList: IRecordInformation[];
}
deleteRecordInformation(_: null, args: IListRecordInformation) {
const recordInformationList = args.RecordInformationList;
return recordInformationList.map((recordInfo) => OtherDescription.destroy({
where: { id: recordInfo.OtherID }
}));
},
1 回答
您可以使用
Promise.all()
传递recordInformationList
然后使用带链接.then()
的.every()
来检查返回的Promise
值