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

249
Views
Sequelize filter the included tables by where

I am trying to findAll records included nested tables, but did not understand how could I filter included tables by where clause. Here are the words:

const players = await PlayerService.findPlayers({
    attributes: { exclude: ['password'] },
    include: [
      { all: true },
      {
        model: Team,
        as: 'captainTeams',
        attributes: {exclude: ['createdAt', 'updatedAt']}
      },
      {
        model: Team,
        as: 'teams',
        where: { type: 1 },
        required: true,
        through: {attributes: []},
        attributes: {exclude: ['createdAt', 'updatedAt']}
      }
    ]
  })

Here is the result:

enter image description here

If I delete where and required from including Team clause, here is the result:

enter image description here

I would like to filter teams.type=2. Could you help me ?

about 4 years ago · Juan Pablo Isaza
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!