Skip to content

Commit

Permalink
feat: script prisma adicionado
Browse files Browse the repository at this point in the history
  • Loading branch information
rafx01 committed Jan 3, 2024
1 parent 96878c5 commit 0144342
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
"dependencies": {
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@prisma/client": "^5.7.1",
"@prisma/client": "5.7.1",
"@remix-run/css-bundle": "^1.19.3",
"@remix-run/node": "^1.19.3",
"@remix-run/react": "^1.19.3",
"@remix-run/serve": "^1.19.3",
"isbot": "^3.6.8",
"mongodb": "^6.3.0",
"prisma": "^5.7.1",
"prisma": "5.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
3 changes: 1 addition & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ datasource db {

model Champions {
id String @id @default(auto()) @map("_id") @db.ObjectId
team String
driver String
driverCountry String
copilot String
copilotCountry String
car String
year Int
year String
}
25 changes: 25 additions & 0 deletions prisma/script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function main() {
const addChampion = await prisma.user.create({
data: {
driver: "Sandro Munari",
driverCountry:"Italy",
copilot: "Pierro Sodano",
copilotCountry: "Italy",
car: "Fiat 131 Abarth",
year: "1977"
},
});

console.log(`New champion added: ${addChampion.driver, addChampion.copilot}`, addChampion);
}

main()
.catch(e => {
throw e
})
.finally(async () => {
await prisma.$disconnect()
});

0 comments on commit 0144342

Please sign in to comment.