From c7eab15972d04c86fe0990de4411adba8c2b87ee Mon Sep 17 00:00:00 2001 From: Jon Harrell <4829245+jharrell@users.noreply.github.com> Date: Tue, 7 Nov 2023 08:38:22 -0600 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Alex Ruheni <33921841+ruheni@users.noreply.github.com> --- .../06-typesafe-raw-sql/01-safeql-gis.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/300-guides/500-other/900-advanced-database-tasks/06-typesafe-raw-sql/01-safeql-gis.mdx b/content/300-guides/500-other/900-advanced-database-tasks/06-typesafe-raw-sql/01-safeql-gis.mdx index 95ef8c24e1..65421c945c 100644 --- a/content/300-guides/500-other/900-advanced-database-tasks/06-typesafe-raw-sql/01-safeql-gis.mdx +++ b/content/300-guides/500-other/900-advanced-database-tasks/06-typesafe-raw-sql/01-safeql-gis.mdx @@ -53,11 +53,11 @@ CREATE EXTENSION IF NOT EXISTS "postgis"; ``` -Make sure that the migration is applied! +Make sure that the migration is applied by running `prisma migrate status`. ## 2. Create a new model that uses a geographic data column -After the migration is applied, you can now add a new model that has a GIS column. For our example we'll be using the following `PointOfInterest` model. +After the migration is applied, you can now add a new model that has a GIS column. For our example, we'll be using a model called `PointOfInterest`. ```prisma model PointOfInterest { @@ -69,7 +69,7 @@ model PointOfInterest { You'll notice that `location` is marked as `Unsupported`. This means that we lose a lot of the benefits of Prisma when working with `PointOfInterest`. We'll be using [SafeQL](https://safeql.dev/) to fix this. -Create a new migration with `npx prisma migrate dev` and apply it to add the `PointOfInterest` table to our database. +Run the `prisma migrate dev` command to create a migration and the table `PointOfInterest` table in your database. ## 3. Integrate SafeQL @@ -85,7 +85,7 @@ Note that for SafeQL to run it will need to have access to your database. We rec Now let's make a Prisma Client extension in order to query this model. We will be making an extension that finds the closest points of interest to a given longitude and latitude. -```ts file=lib/db.ts +```ts file=lib/prisma.ts import { PrismaClient } from '@prisma/client' const prisma = new PrismaClient().$extends((client) => { @@ -109,7 +109,7 @@ const prisma = new PrismaClient().$extends((client) => { export { prisma } ``` -Now we can use our Prisma Client as normal in order to find close points of interest to a given longitude and latitude! +Now, you can use our Prisma Client as normal to find close points of interest to a given longitude and latitude using the custom method created on the `PointOfInterest` model. ```ts file=app.ts const closestPointOfInterest = await prisma.pointOfInterest.findClosestPoints(