Skip to content

Commit

Permalink
polishing from the cli guide
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Feb 1, 2025
1 parent c486375 commit b0d27c5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions content/100-getting-started/03-prisma-postgres/100-from-the-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ npx tsc --init
Install the required dependencies to use Prisma Postgres:

```terminal
npm install prisma --save-de
npm install prisma --save-dev
npm install @prisma/extension-accelerate
```

Expand Down Expand Up @@ -186,12 +186,13 @@ This code contains a `main` function that's invoked at the end of the script. It

### 4.1. Create a new `User` record

Let's start with a small query to create a new `User` record in the database and log the resulting object to the console. Add the following code to your `script.ts` file:
Let's start with a small query to create a new `User` record in the database and log the resulting object to the console. Add the following code to your `index.ts` file:

```ts file=index.ts
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient()
const prisma = new PrismaClient().$extends(withAccelerate())

async function main() {
// add-start
Expand Down Expand Up @@ -223,7 +224,7 @@ Next, execute the script with the following command:
<cmd>

```terminal
npx tsx script.ts
npx tsx index.ts
```
</cmd>

Expand All @@ -247,8 +248,9 @@ Delete the previous Prisma ORM query and add the new `findMany` query instead:

```ts file=index.ts
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient()
const prisma = new PrismaClient().$extends(withAccelerate())

async function main() {
// add-start
Expand All @@ -275,7 +277,7 @@ Execute the script again:
<cmd>

```terminal
npx tsx script.ts
npx tsx index.ts
```

</cmd>
Expand All @@ -300,8 +302,9 @@ First, adjust your script to include the nested query:

```ts file=index.ts
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient()
const prisma = new PrismaClient().$extends(withAccelerate())

async function main() {
// add-start
Expand Down Expand Up @@ -345,7 +348,7 @@ Run the query by executing the script again:
<cmd>

```terminal
npx tsx script.ts
npx tsx index.ts
```

</cmd>
Expand All @@ -364,8 +367,9 @@ In order to also retrieve the `Post` records that belong to a `User`, you can us

```ts file=index.ts
import { PrismaClient } from '@prisma/client'
import { withAccelerate } from '@prisma/extension-accelerate'

const prisma = new PrismaClient()
const prisma = new PrismaClient().$extends(withAccelerate())

async function main() {
// add-start
Expand Down Expand Up @@ -396,7 +400,7 @@ Run the script again to see the results of the nested read query:
<cmd>

```terminal
npx tsx script.ts
npx tsx index.ts
```

</cmd>
Expand Down

0 comments on commit b0d27c5

Please sign in to comment.