forked from prisma/prisma-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- There is no login or signup mechanism. - Signup button adds new author - This commit simply renames UI text to reflect that more clearly
- Loading branch information
1 parent
ac01f3b
commit 54f510d
Showing
5 changed files
with
21 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,6 @@ npx prisma migrate dev --name init | |
|
||
When `npx prisma migrate dev` is executed against a newly created database, seeding is also triggered. The seed file in [`prisma/seed.ts`](./prisma/seed.ts) will be executed and your database will be populated with the sample data. | ||
|
||
|
||
### 3. Start the app | ||
|
||
``` | ||
|
@@ -63,7 +62,7 @@ The app is now running, navigate to [`http://localhost:3000/`](http://localhost: | |
|
||
 | ||
|
||
**Signup** (located in [`./pages/signup.tsx`](./pages/signup.tsx)) | ||
**Add Author** (located in [`./pages/add-author.tsx`](./pages/add-author.tsx)) | ||
|
||
 | ||
|
||
|
@@ -137,8 +136,8 @@ model Post { | |
} | ||
|
||
model User { | ||
id Int @default(autoincrement()) @id | ||
name String? | ||
id Int @default(autoincrement()) @id | ||
name String? | ||
email String @unique | ||
posts Post[] | ||
+ profile Profile? | ||
|
@@ -167,56 +166,54 @@ You can now use your `PrismaClient` instance to perform operations against the n | |
```ts | ||
const profile = await prisma.profile.create({ | ||
data: { | ||
bio: "Hello World", | ||
bio: 'Hello World', | ||
user: { | ||
connect: { email: "[email protected]" }, | ||
connect: { email: '[email protected]' }, | ||
}, | ||
}, | ||
}); | ||
}) | ||
``` | ||
|
||
#### Create a new user with a new profile | ||
|
||
```ts | ||
const user = await prisma.user.create({ | ||
data: { | ||
email: "[email protected]", | ||
name: "John", | ||
email: '[email protected]', | ||
name: 'John', | ||
profile: { | ||
create: { | ||
bio: "Hello World", | ||
bio: 'Hello World', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}) | ||
``` | ||
|
||
#### Update the profile of an existing user | ||
|
||
```ts | ||
const userWithUpdatedProfile = await prisma.user.update({ | ||
where: { email: "[email protected]" }, | ||
where: { email: '[email protected]' }, | ||
data: { | ||
profile: { | ||
update: { | ||
bio: "Hello Friends", | ||
bio: 'Hello Friends', | ||
}, | ||
}, | ||
}, | ||
}); | ||
}) | ||
``` | ||
|
||
|
||
### 3. Build new UI features in React | ||
|
||
Once you have added a new endpoint to the API (e.g. `/api/profile` with `/POST`, `/PUT` and `GET` operations), you can start building a new UI component in React. It could e.g. be called `profile.tsx` and would be located in the `pages` directory. | ||
|
||
In the application code, you can access the new endpoint via `fetch` operations and populate the UI with the data you receive from the API calls. | ||
|
||
|
||
## Switch to another database (e.g. PostgreSQL, MySQL, SQL Server, MongoDB) | ||
|
||
If you want to try this example with another database than SQLite, you can adjust the the database connection in [`prisma/schema.prisma`](./prisma/schema.prisma) by reconfiguring the `datasource` block. | ||
If you want to try this example with another database than SQLite, you can adjust the the database connection in [`prisma/schema.prisma`](./prisma/schema.prisma) by reconfiguring the `datasource` block. | ||
|
||
Learn more about the different connection configurations in the [docs](https://www.prisma.io/docs/reference/database-reference/connection-urls). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ input[type='submit'] { | |
background: #ececec; | ||
border: 0; | ||
padding: 1rem 2rem; | ||
margin: 0.5rem; | ||
} | ||
|
||
nav { | ||
|