First is it possible, I think it should be as they're safer than raw queries and prevent sql injection.
But there is literally nothing I can find in documentation.
sequelize.prepare
<- doesn't exist
sequelize.query
<- exists
First is it possible, I think it should be as they're safer than raw queries and prevent sql injection.
But there is literally nothing I can find in documentation.
sequelize.prepare
<- doesn't exist
sequelize.query
<- exists
- Did you ever get an answer to this? – Shayne Commented Feb 16, 2024 at 8:24
1 Answer
Reset to default 15Never Mind, The sequelize.query
has an option called replacements
that is escaped automatically.
replacements are escaped and inserted into the query by sequelize before the query is sent to the database
sequelize.query('SELECT * FROM users WHERE name LIKE :search_name ',
{ replacements: { search_name: 'ben%' }, type: sequelize.QueryTypes.SELECT }
).then(projects => {
console.log(projects)
})