Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!