I will contextualize with models:
const Tab1 = sequelize.define('tab1', {
name: sequelize.STRING,
tab2_id: sequelize.INTEGER
})
const Tab2 = sequelize.define('tab2', {
title: sequelize.STRING
})
// relacionamento
Tab1.belongsTo(Tab2, {
foreignKey: 'tab2_id'
})
Now to the query itself where $OR
is performed with both tables:
return Tab1.findAll({
where: {
$or: [
{
name: {
$like: '%blabla%'
}
},
['\'Tab2\'.\'title\') LIKE ?', '%blablabla%'] // aqui é o macete
]
},
include: [
Tab2
]
})
Sequelize does not deliver this kind of detail in the documentation but it is very customizable, there are several ways to do the same, more or less to the letter.