-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: fix the getting started seed.ts content
- Loading branch information
Showing
1 changed file
with
10 additions
and
9 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 |
---|---|---|
|
@@ -126,7 +126,7 @@ generator client { | |
} | ||
datasource db { | ||
provider = "postgresql" | ||
provider = "sqlite" | ||
url = env("DATABASE_URL") | ||
} | ||
|
@@ -179,7 +179,7 @@ And you can add the `seed.ts` next to your schema file (don't forget to add the | |
{ | ||
"prisma": { | ||
"schema": "prisma/schema.prisma", | ||
"seed": "npx ts-node --project ./prisma/seed.ts" | ||
"seed": "npx ts-node --project tsconfig.json ./prisma/seed.ts" | ||
} | ||
} | ||
``` | ||
|
@@ -188,28 +188,28 @@ Note: you will need to install `@ngneat/falso` as a dev dependency and to add th | |
|
||
```typescript | ||
import { randFirstName, randLastName, randText } from '@ngneat/falso'; | ||
import { PrismaClient, Role } from '@prisma/client'; | ||
import { PrismaClient } from '@prisma/client'; | ||
import * as bcrypt from 'bcrypt'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
export function createUser({ | ||
email, | ||
password, | ||
roles, | ||
role, | ||
sharedTasksWith = [], | ||
}: { | ||
email: string; | ||
password: string; | ||
roles: Role[]; | ||
role: string; | ||
sharedTasksWith?: string[]; | ||
}) { | ||
console.info(`Creating user ${email}`); | ||
return prisma.user.create({ | ||
data: { | ||
email, | ||
password: bcrypt.hashSync(password, 10), | ||
roles, | ||
role, | ||
profile: { | ||
create: { | ||
firstName: randFirstName(), | ||
|
@@ -242,17 +242,17 @@ async function seed() { | |
await createUser({ | ||
email: '[email protected]', | ||
password: 'password', | ||
roles: [Role.admin], | ||
role: 'admin', | ||
}), | ||
await createUser({ | ||
email: '[email protected]', | ||
password: 'password', | ||
roles: [Role.user], | ||
role: 'user', | ||
}), | ||
await createUser({ | ||
email: '[email protected]', | ||
password: 'password', | ||
roles: [Role.user], | ||
role: 'user', | ||
sharedTasksWith: ['[email protected]'], | ||
}), | ||
]; | ||
|
@@ -264,6 +264,7 @@ seed().catch((e) => { | |
console.error(e); | ||
process.exit(1); | ||
}); | ||
|
||
``` | ||
|
||
## User Authentication | ||
|