-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
479900c
commit cb4a59f
Showing
6 changed files
with
1,944 additions
and
3,091 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
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { db } from '$api/src/lib/db' | ||
|
||
export default async () => { | ||
try { | ||
// | ||
// Manually seed via `yarn rw prisma db seed` | ||
// Seeds automatically with `yarn rw prisma migrate dev` and `yarn rw prisma migrate reset` | ||
// | ||
// Update "const data = []" to match your data model and seeding needs | ||
// | ||
const data = [ | ||
// To try this example data with the UserExample model in schema.prisma, | ||
// uncomment the lines below and run 'yarn rw prisma migrate dev' | ||
// | ||
// { name: 'alice', email: 'alice@example.com' }, | ||
// { name: 'mark', email: 'mark@example.com' }, | ||
// { name: 'jackie', email: 'jackie@example.com' }, | ||
// { name: 'bob', email: 'bob@example.com' }, | ||
] | ||
console.log( | ||
"\nUsing the default './scripts/seed.js' template\nEdit the file to add seed data\n" | ||
) | ||
|
||
// Note: if using PostgreSQL, using `createMany` to insert multiple records is much faster | ||
// @see: https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#createmany | ||
Promise.all( | ||
// | ||
// Change to match your data model and seeding needs | ||
// | ||
data.map(async (userExample) => { | ||
const record = await db.userExample.create({ | ||
data: { name: userExample.name, email: userExample.email }, | ||
}) | ||
|
||
console.log(record) | ||
}) | ||
) | ||
} catch (error) { | ||
console.warn('Please define your seed data.') | ||
console.error(error) | ||
} | ||
} |
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
Oops, something went wrong.