You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/recipes/prisma.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,35 +41,35 @@ See the [First steps](https://docs.nestjs.com/first-steps) page to learn more ab
41
41
Start by installing the Prisma CLI as a development dependency in your project:
42
42
43
43
```bash
44
-
npm install @prisma/cli --save-dev
44
+
$ npm install @prisma/cli --save-dev
45
45
```
46
46
47
47
As a best practice, it's recommended to invoke the CLI locally by prefixing it with `npx`:
48
48
49
49
```bash
50
-
npx prisma
50
+
$ npx prisma
51
51
```
52
52
53
53
<details><summary>Expand if you're using Yarn</summary>
54
54
55
55
If you're using Yarn, then you can install the Prisma CLI as follows:
56
56
57
57
```bash
58
-
yarn add @prisma/cli --dev
58
+
$ yarn add @prisma/cli --dev
59
59
```
60
60
61
61
Once installed, you can invoke it by prefixing it with `yarn`:
62
62
63
63
```bash
64
-
yarn prisma
64
+
$ yarn prisma
65
65
```
66
66
67
67
</details>
68
68
69
69
Now create your initial Prisma setup using the `init` command of the Prisma CLI:
70
70
71
71
```bash
72
-
npx prisma init
72
+
$ npx prisma init
73
73
```
74
74
75
75
This command created a new `prisma` directory with the following contents:
@@ -171,7 +171,7 @@ In this section, you'll create two new tables in your database. Run the followin
171
171
**Mac OS / Linux**
172
172
173
173
```bash
174
-
sqlite3 dev.db \
174
+
$ sqlite3 dev.db \
175
175
'CREATE TABLE "User" (
176
176
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
177
177
"name" TEXT,
@@ -190,7 +190,7 @@ CREATE TABLE "Post" (
190
190
**Windows**
191
191
192
192
```bash
193
-
sqlite3 ./prisma/dev.db
193
+
$ sqlite3 ./prisma/dev.db
194
194
CREATE TABLE "User" (
195
195
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
196
196
"name" TEXT,
@@ -214,7 +214,7 @@ Now that you created your database tables, you can _introspect_ the database to
214
214
To introspect your database, run the following command in your terminal:
215
215
216
216
```bash
217
-
npx prisma introspect
217
+
$ npx prisma introspect
218
218
```
219
219
220
220
This reads your SQL schema and translates each table into a corresponding Prisma model. Your `schema.prisma` file now looks as follows:
@@ -253,7 +253,7 @@ With your Prisma models in place, you can install and generate Prisma Client.
253
253
To install Prisma Client in your project, run the following command in your terminal:
254
254
255
255
```bash
256
-
npm install @prisma/client
256
+
$ npm install @prisma/client
257
257
```
258
258
259
259
Note that this command automatically invokes the `prisma generate` command for you. In the future, you need to run this command after _every_ change to your Prisma models to update your generated Prisma Client.
@@ -552,9 +552,8 @@ This controller implements the following routes:
552
552
553
553
-`/post/:id`: Delete a post by its `id`
554
554
555
-
556
555
#### Summary
557
556
558
557
In this guide, you learned how to implement a use NestJS together with Prisma to implement a REST API. The controller who implements the routes of the API is calling a `PrismaService` which in turn uses Prisma Client to send queries to a database to fulfill the data needs of incoming requests.
559
558
560
-
If you want to learn more about Prisma, be sure to check out the [documentation](https://www.prisma.io/docs/).
559
+
If you want to learn more about Prisma, be sure to check out the [documentation](https://www.prisma.io/docs/).
0 commit comments