Getting errors in following TypeORM query:
async exportUsers(stateId: string, zipcodes: string)
{
//zipcodes = '60563', '54656', '94087';//
const query = await this.userRepository
.createQueryBuilder('user')
.select('user.email', 'email')
.where('left(user.Zip,5) in :zip', { zip: zipcodes });
}
How to pass string containing 'array of strings' to TypeORM query using IN.
This worked:
zipcodes = '60563', '54656', '94087';
const ziplist: string[] = zipcodes.replace("'", "").split(",");
Changed query to:
.where('left(s.ShipToZip,5) in (:...zip)', { zip: ziplist });