Skip to content

Commit

Permalink
add initial input and output templates in seed.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dysmento committed Jan 18, 2024
1 parent 92a971c commit b48a5fe
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions scripts/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit b48a5fe

Please sign in to comment.