Skip to content
Snippets Groups Projects
Commit 5697b43f authored by Jan Hudec's avatar Jan Hudec
Browse files

feat: database seed for meals added

parent 78d4c644
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,8 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon src/index.ts",
"migrate": "npx prisma migrate dev --name 'init' --preview-feature"
"migrate": "npx prisma migrate dev --name 'init' --preview-feature",
"seed": "ts-node prisma/seed.ts"
},
"author": "",
"license": "ISC",
......
import { PrismaClient } from '@prisma/client'
import {seedMeal} from "./seeds";
const prisma = new PrismaClient()
const main = async () => {
console.log('seeding started')
await seedMeal();
console.log('seeding done');
}
main()
.catch(e => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})
import {seedMeal} from "./meal";
export {
seedMeal
}
import prisma from "../../src/client";
//Seeds a meal
export const seedMeal = async () => {
await prisma.meal.create({
data: {
name: 'smazak',
description: 'smazeny syr s hranolky a tatarkou',
price: 110,
},
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment