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

430
Views
findAll() in Sequelize doesn't find a row created inside a transaction

I'm having a problem when creating a row and later on selecting it while still under the same transaction.

Whenever I execute the following code I usually get an empty array and rarely get an array with the newly created row.

This is a sample of the code I run:

return seq.transaction((tx) => {
    const options = {transaction: tx};
    return model.create(user, options)
    .then(() => {
        return model.findAll({
            include: {
                all: true
            }
    }, options)
    .then((data) => ({
        console.log(data);
    });
});

Is there something basic I'm missing here? Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I solved the problem. What I did wrong was giving the transaction to the findAll() function as an additional argument instead of part of the first argument's JSON.

So instead of:

return model.findAll({
    include: {
        all: true
    }
}, options)

I should've done:

return model.findAll({
    include: {
        all: true
    },
    transaction: options.transaction
});

Hope this solution will be helpful for other people.

over 4 years ago · Santiago Trujillo 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!