Skip to content

Commit

Permalink
Moved seeds data to dedicated folder
Browse files Browse the repository at this point in the history
Created seeding utility to avoid code-repetition
  • Loading branch information
LobeTia committed Apr 29, 2024
1 parent 18b7188 commit 5f55830
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions prisma/seeds/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import {PrismaClient} from '@prisma/client'

import {membershipTemplates} from "./membershipTemplates";
import {users} from "./users";
import {membershipTemplates} from "./models/membershipTemplates";
import {users} from "./models/users";

const prisma = new PrismaClient()

async function main() {
await prisma.user.createMany({
data: users,
skipDuplicates: true
})
function seedModel(model: any, data: object[]) {
return model.createMany({data, skipDuplicates: true})
}

await prisma.membershipTemplate.createMany({
data: membershipTemplates,
skipDuplicates: true
})
async function main() {
await seedModel(prisma.user, users)
await seedModel(prisma.membershipTemplate, membershipTemplates)
}

main()
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 5f55830

Please sign in to comment.