'How to perform multiple queries that require a specific order, but if one fails then revert all of the queries that have been executed?
I have multiple queries that need to run in a specific order, and the result of some of the queries is required in the next query. I want to have some condition that if one of the queries fails then all of them should fail (even the ones that have already been queried). Is there a way to lump them all together that way?
const request = await privateCloudActiveRequests.findOneById(id);
const updatedRequest = await privateCloudRequests.save({
...request,
...{
status: "rejected",
decisionDate: new Date(),
active: false,
decisionMaker: "Jane",
},
});
await privateCloudActiveRequests.removeDocument(id);
return updatedRequest;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
