Почему Sequelize с вложенным включением не скрывает первичный ключ? - PullRequest
0 голосов
/ 08 июля 2020

В этом примере мне нужно только поле name из таблицы qux.

bar
  .findAll({
    raw: true,
    attributes: { exclude: ["createdAt", "updatedAt"] },
    include: [{ 
      model: foo,       
      attributes: ["name"],       
      include: [{ 
        model: qux,        
        attributes:['name'],                
      }] 
    }],
  })
  .then((resp) => {
    console.log(resp)
  })

Но я не могу удалить первичный ключ foos.quxes.id из результата.

  {
    id: 1,
    name: 'colors',
    'foos.name': 'green',
    'foos.quxes.id': 6,
    'foos.quxes.name': 'light'
  }

У меня такие ассоциации:

foo.belongsTo(bar, {foreignKey:'barId', allowNull:true } )
bar.hasMany(foo)

qux.belongsTo(foo, { foreignKey: "fooId", allowNull: true })
foo.hasMany(qux)

Не могли бы вы мне с этим помочь? С уважением!

...