I am developing a simple blog which includes users and posts. Users and Posts have different fields. I want to search for a keyword using one function. To achieve it, I should be able to search using sequelize from multiple columns. For more information, I provide the contents of models as a dictionary below.
Users = {
'firstName': Sequelize.STRING,
'email': Sequelize.STRING,
'password': Sequelize.STRING,
}
Posts = {
'title': Sequelize.STRING,
'content': Sequelize.TEXT,
}
What I want to achieve:
model.findAll({
where: {
*: {
[Op.iLike]: "%searchingkeyword%"
}
})
// Imagine model is passed to function and it can either be Users or Posts
*: means all fields
Question: How to search over multiple fields withouth specifically writing them?