Use Promise.all([p1, p2]) to operate two promise functions. Both functions use mongoose internally to operate the database.
If p1 is rejected and p2 is resolved.
My question is, p2 has actually performed operations on the database. Is that so? Or does promise.all ensure that both p1 and p2 resolve before performing actual database operations?
It feels like it is a mongoose transactional issue.
Promise.all resolves when all given iterables complete, or rejects when any promises fail.
If any promises are passed that rejects , all Promise values immediately fail, discarding all other promises if they are unresolved. If passed any empty array, this method will complete immediately.
1) Every promise in promise all will be executed
2) At this time, the status of p becomes rejected
For your situation, I happened to write a package, https://github.com/zaaack/mon... It should be able to meet your needs