...

/

Using SQL Queries Directly with Prisma and TypeORMs

Using SQL Queries Directly with Prisma and TypeORMs

Learn how to write SQL query strings directly using Prisma and TypeORMs.

Introduction

ORMs are very handy because they write SQL queries behind the scenes. We may sometimes want to write this query ourselves, for one or several reasons. In this lesson, we’ll take a deep dive into how to achieve this with the ORM libraries we’ve discussed so far.

Prisma

The $queryRaw method

This method allows us to write custom SQL queries. In the code given below, we first import the PrismaClient class from which the $queryRaw method is derived. We then make a simple SELECT SQL query to get all the employee records.

Since these custom SQL queries ...