Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fawn not rolling back to the first query (i have 3 queries), Please help ! #82

Open
fabiokounang opened this issue Apr 27, 2020 · 0 comments

Comments

@fabiokounang
Copy link

so, i have 3 queries, i make the third query error on purpose, but it does not rolling back until the first query, it's just rolling back to the second query. Please help !

try {
    const task = Fawn.Task();
    const winner = new Winner({ type: req.body.type, coupon: req.body.coupon });    
    await task
      .save(Winner, winner)
      .update(Transaction, { coupon: req.body.coupon, type: req.body.type, createdAt: query }, {
        $set: {
          win: "1",
          status_trx: "1"
        }
      })
      .update(Transaction, {    
        status_trx: "2",
        type: req.body.type,
        createdAt: query
      },
      {
        $set: {
          win: "3",
          status_trx: "3"
        }
      }).options({ multi: true });
    const result = await task.run({useMongoose: true});
    console.log(JSON.stringify(result));
  } catch (err) {
    console.log(err); // it throw error but does not rolling back until the first query
  } finally {
    res.send(true);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant