-
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.
add initial input and output templates in seed.ts
- Loading branch information
Showing
1 changed file
with
30 additions
and
17 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 |
---|---|---|
|
@@ -7,31 +7,44 @@ export default async () => { | |
// 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: Prisma.UserExampleCreateArgs['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: '[email protected]' }, | ||
// { name: 'mark', email: '[email protected]' }, | ||
// { name: 'jackie', email: '[email protected]' }, | ||
// { name: 'bob', email: '[email protected]' }, | ||
|
||
const inputTemplates: Prisma.InputTemplateCreateArgs['data'][] = [ | ||
{ | ||
name: 'Input Template 1', | ||
version: '1.0.0', | ||
effectiveDate: new Date(), | ||
}, | ||
] | ||
|
||
const outputTemplates: Prisma.OutputTemplateCreateArgs['data'][] = [ | ||
{ | ||
name: 'Output Template 1', | ||
version: '1.0.0', | ||
effectiveDate: new Date(), | ||
}, | ||
] | ||
console.log( | ||
"\nUsing the default './scripts/seed.{js,ts}' 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 | ||
await Promise.all( | ||
// | ||
// Change to match your data model and seeding needs | ||
// | ||
data.map(async (data: Prisma.UserExampleCreateArgs['data']) => { | ||
const record = await db.userExample.create({ data }) | ||
console.log(record) | ||
}) | ||
inputTemplates.map( | ||
async (data: Prisma.InputTemplateCreateArgs['data']) => { | ||
const record = await db.inputTemplate.create({ data }) | ||
console.log(record) | ||
} | ||
) | ||
) | ||
|
||
await Promise.all( | ||
outputTemplates.map( | ||
async (data: Prisma.OutputTemplateCreateArgs['data']) => { | ||
const record = await db.outputTemplate.create({ data }) | ||
console.log(record) | ||
} | ||
) | ||
) | ||
|
||
// If using dbAuth and seeding users, you'll need to add a `hashedPassword` | ||
|