Skip to content

Lucid: Truncate within transaction #1375

Answered by thetutlage
rbartholomay asked this question in Help
Discussion options

You must be logged in to vote

Use this

await Database.transaction(async (trx) => {
  await trx.truncate(MyLucidModel.table)
  await MyLucidModel.createMany(data, { client: trx })
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rbartholomay
Comment options

Answer selected by rbartholomay
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants