Search code examples
sequelize.jsgraphqlgraphql-jsexpress-graphql

self._expandAttributes is not a function


 ppvPlanDb.models.ppv_plans.findAll({

                attributes: ['id', 'studio_id', 'status', 'is_advance_purchase','content_types_id' ],
                where: sequelize.and(sequelize.where(sequelize.col('ppv_plans.status'), '=', 1,sequelize.col('ppv_plans.studio_id'), '=', studio_id,sequelize.col('ppv_plans.is_advance_purchase'), '=', 1,sequelize.col('ppv_plans.content_types_id'), '', (1,4))),
                include: [{
                    model: ppvAdvanceContentDb.models.ppv_advance_content.findAll(),
                    required: false
                }]
            })

why it is showing error in console?? Is there any wrong? I am confused about how to join two tables in sequelize. Here I am trying to join two tables (ppv_plans and ppv_advance_content). Please tell me.


Solution

  • You don't need to add the call to .findAll(), model field should be just the reference to the associated model

    Reference: https://sequelize.org/master/manual/eager-loading.html#fetching-all-associated-elements