Skip to content

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

@fabiokounang

Description

@fabiokounang

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);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions