perdón por mi inglés. Quiero hacer múltiples asociaciones de inclusión dentro de un findOne usando Sequelize. Cuando lo hago por separado incluye todo funciona perfectamente. Voy a contrastar a continuación lo que funciona y lo que no.
// that doesn't work const post = await Post.findOne({ where: { post_url: post_url }, include: { // this include dont work association: 'postAuthor', attributes: ['name'], }, include: { association: 'comments', attributes: ['comment'], include: { association: 'commentAuthor', attributes: ['name'] } } });Pero si hago cada oración por separado, funciona.
// this work include: { association: 'postAuthor', attributes: ['name'], },Nuevamente lo siento por los ingleses.
En resumen, necesito hacer que ambas funciones funcionen al mismo tiempo. El include dentro del include funciona perfectamente (commentAuthor In comments).
where: { post_url: post_url }, include: [ { association: 'postAuthor', attributes: ['name'] }, { association: 'comments', attributes: ['comment'], include: [{ association: 'commentAuthor', attributes: ['name'] }] } ] });