First commit.

This commit is contained in:
Colin Diem
2022-04-12 19:51:12 -04:00
commit 6131eda9f6
49 changed files with 25563 additions and 0 deletions

39
scripts/seed.js Normal file
View File

@@ -0,0 +1,39 @@
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,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
Promise.all(
//
// Change to match your data model and seeding needs
//
data.map(async (data) => {
const record = await db.userExample.create({ data })
console.log(record)
})
)
} catch (error) {
console.warn('Please define your seed data.')
console.error(error)
}
}