Node.js sequelize raw query with condition in array of string

Example use case of how to use sequelize raw query for retrieving results from Postgresql database with condition that the where condition must be in array of string.

Donald Le
1 min readFeb 1, 2023
Photo by <a href=”">Rayyu Maldives</a> on <a href=”">Unsplash</a>

For example, we want to do a query string like this in SQL:

select id from projects where id in (
) and labeling_type='type';

To do that in Node.js sequelize, we write the code like below:

const directionsArray=Array.from(directions.values())

const [resultsFilterBySingleFrameProject] = await (await postgresqlClient).query(`select id from projects where id in (:id) and labeling_type='${projectType}';`,{
replacements: {id:directionsArray},

Hope it helps~~




Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.