Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

319
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda