Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toc: false

<SwitchTech technologies={['*', 'postgresql']}>

In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your Prisma schema in `prisma/schema.prisma`:
In this guide, you'll use [Prisma Migrate](/concepts/components/prisma-migrate) to create the tables in your database. Add the following Prisma data model to your [Prisma schema](/concepts/components/prisma-schema) in `prisma/schema.prisma`:

```prisma file=prisma/schema.prisma copy
model Post {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ toc: false

## Write your first query with Prisma Client

Now that you have generated Prisma Client, you can start writing queries to read and write data in your database. For the purpose of this guide, you'll use a plain Node.js script to explore some basic features of Prisma Client.
Now that you have generated [Prisma Client](/concepts/components/prisma-client), you can start writing queries to read and write data in your database. For the purpose of this guide, you'll use a plain Node.js script to explore some basic features of Prisma Client.

<SwitchTech technologies={['typescript', '*']}>

Expand Down Expand Up @@ -129,7 +129,7 @@ Adjust the `main` function to send a `create` query to the database:

<SwitchTech technologies={['typescript', '*']}>

```ts file=index.ts copy
```ts file=index.ts highlight=2-21;add copy
async function main() {
await prisma.user.create({
data: {
Expand Down Expand Up @@ -158,7 +158,7 @@ async function main() {

<SwitchTech technologies={['node', '*']}>

```js file=index.js copy
```js file=index.js highlight=2-21;add copy
async function main() {
await prisma.user.create({
data: {
Expand Down Expand Up @@ -219,6 +219,7 @@ The output should look similar to this:
{
content: null,
createdAt: 2020-03-21T16:45:01.246Z,
updatedAt: 2020-03-21T16:45:01.246Z,
id: 1,
published: false,
title: 'Hello World',
Expand Down Expand Up @@ -264,9 +265,9 @@ The query added new records to the `User` and the `Post` tables:

**Post**

| **id** | **createdAt** | **title** | **content** | **published** | **authorId** |
| :----- | :------------------------- | :-------------- | :---------- | :------------ | :----------- |
| `1` | `2020-03-21T16:45:01.246Z` | `"Hello World"` | `null` | `false` | `1` |
| **id** | **createdAt** | **updatedAt** | **title** | **content** | **published** | **authorId** |
| :----- | :------------------------- | :------------------------: | :-------------- | :---------- | :------------ | :----------- |
| `1` | `2020-03-21T16:45:01.246Z` | `2020-03-21T16:45:01.246Z` | `"Hello World"` | `null` | `false` | `1` |

**Profile**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const deletedUser = await prisma.user.delete({

### Explore the data in Prisma Studio

Prisma Studio is a visual editor for the data in your database. Run `$ npx prisma studio` in your terminal.
Prisma Studio is a visual editor for the data in your database. Run `npx prisma studio` in your terminal.

### Try a Prisma example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

async function main() {
// Connect the client
await prisma.$connect()
// ... you will write your Prisma Client queries here
}

Expand All @@ -49,8 +47,6 @@ const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()

async function main() {
// Connect the client
await prisma.$connect()
// ... you will write your Prisma Client queries here
}

Expand Down Expand Up @@ -82,8 +78,6 @@ Inside the `main` function, add the following query to read all `User` records f

```ts file=index.ts
async function main() {
// Connect the client
await prisma.$connect()
// ... you will write your Prisma Client queries here
+ const allUsers = await prisma.user.findMany()
+ console.log(allUsers)
Expand All @@ -96,8 +90,6 @@ async function main() {

```js file=index.js
async function main() {
// Connect the client
await prisma.$connect()
- // ... you will write your Prisma Client queries here
+ const allUsers = await prisma.user.findMany()
+ console.log(allUsers)
Expand Down Expand Up @@ -138,10 +130,8 @@ Adjust the `main` function to send a `create` query to the database:

<SwitchTech technologies={['typescript', '*']}>

```ts file=index.ts copy
```ts file=index.ts highlight=2-21;add copy
async function main() {
await prisma.$connect()

await prisma.user.create({
data: {
name: 'Rich',
Expand Down Expand Up @@ -169,10 +159,8 @@ async function main() {

<SwitchTech technologies={['node', '*']}>

```js file=index.js copy
```js file=index.js highlight=2-21;add copy
async function main() {
await prisma.$connect()

await prisma.user.create({
data: {
name: 'Rich',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const deletedUser = await prisma.user.delete({

### Explore the data in Prisma Studio

Prisma Studio is a visual editor for the data in your database. Run `$ npx prisma studio` in your terminal.
Prisma Studio is a visual editor for the data in your database. Run `npx prisma studio` in your terminal.

### Try a Prisma example

Expand Down
Loading