Codxplore.com

Latest news:

Sahih al-Bukhari (সহীহ বুখারী) is a free Hadith application for android. This application is advertisement free. Download now https://play.google.com/store/apps/details?id=com.akramhossin.bukharisharif

TypeORM: How to bind parameters in where clause for SelectQueryBuilder


TypeORM: How to bind parameters in where clause for SelectQueryBuilder

Parameters used for

  • As placeholders for the dynamic values in the query
  • To prevent SQL injection

Example

let businessArtists: Artists[] = await getRepository(Artists)
                .createQueryBuilder('artists')
                .leftJoin(LocationArtists, 'location_artists', 'artists.artist_id = location_artists.artist_id')
                .where("artists.business_id =:business_id AND  artists.is_active =:is_active AND artists.is_deleted=:is_deleted AND location_artists.location_id=:location_id", {
                    business_id: business.businessId,
                    is_active: 1,
                    is_deleted: 0,
                    location_id: locationId,
                })
              .getMany()

 


Views : 896

Subscribe Us


Follow Us