{ await.task.oneOrNone('INS" /> { await.task.oneOrNone('INS" /> { await.task.oneOrNone('INS"/>

"Task" doesn't actually chain transactions

33 Views Asked by At

Maybe I'm not using/understanding the "task" object correctly. When I do the following:

   return await db.tx(async (task) => {
      
      await.task.oneOrNone('INSERT INTO message (body) VALUES ('test') RETURNING id)
 
      await task.oneOrNone('INSERT INTO user (name) VALUES ('bob') RETURNING id)

    });

If the first insert fails I would expect for the second insert to fail. This however doesn't not seem to be the case. Please help me understand how to use task correctly from this example.

0

There are 0 best solutions below