Sequelize: Include.where filtering by a ‘parent’ Model attribute

Sequelize provides an extra operator $col for this case so you don’t have to use sequelize.literal('...') (which is more a hack).

In your example the usage would look like this:

Catalog.find({where:
    {id: itemId},
    include: {
        model: models.ProductCategory, 
        where: {
          language_id: {$col: 'Catalog.language_id'}
        }
    }
})

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)