Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

317
Visualizações
Sequelize transactions: Part of the options object, or a separate argument?

The sequelize docs for create, findByPk and findAll state that a transaction should be passed as part of the options argument, here, but I've previously been using it as a separate arg with no issues (afaik):

await Example.create({ 
  // options
}, { transaction: t });

I'd naturally believe the docs, but while looking for examples I've come across a lot of this latter usage, with some even suggesting the docs might be wrong here for example. Was hoping someone could clarify which is correct, or if it even matters?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I would advise looking at the individual methods that you are using within Sequelize to determine the proper place for a transaction property.

Your .create() example above is correct. The first argument to .create() is the CreationAttributes, and the second argument is the options object where the transaction would go. https://sequelize.org/api/v7/classes/model#create

The answer in the link you provided is incorrect. When using findAll(), the transaction property is supposed to go in the FindOptions object, which is the first and only argument to be passed in. The comments to the answer you linked correctly point out that the original poster's issues are related to something else. https://sequelize.org/api/v7/classes/model#findAll

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda