X
Xata7mo ago
RealT

How to run X number of operations in transaction

Hi, I am trying to upsert multiple records. According to the doc, I'll have to create update operations in transaction like before. const result = await xata.transactions.run([ { update: { table: 'titles', id: 'new-1', fields: { originalTitle: 'The third' }, upsert: true } }, ... ]); However, the number of upsert is determined at runtime. Is it possible to pass in a dynamic array of operations into the run function? I have tried the following and it complains a type mismatch. var op1 = { update: { table: 'titles', id: 'new-1', fields: { originalTitle: 'The first' }, upsert: true } }, var op2 = { update: { table: 'titles', id: 'new-2', fields: { originalTitle: 'The second' }, upsert: true } }, var ops = { op1, op2 } const result = await xata.transactions.run([ ops ]);
2 Replies
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
RealT
RealTOP7mo ago
Thanks Esther! It's working as expected 👍🏻
Want results from more Discord servers?
Add your server