Skip to content

Commit e953fec

Browse files
committed
resources
1 parent 8099bb5 commit e953fec

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { PrismaClient } from "@prisma/client";
2+
3+
const prisma = new PrismaClient();
4+
5+
const pets = [
6+
{
7+
name: "Benjamin",
8+
ownerName: "John Doe",
9+
imageUrl:
10+
"https://images.unsplash.com/photo-1517849845537-4d257902454a?auto=format&fit=crop&q=100&w=1935&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
11+
age: 2,
12+
notes:
13+
"Doesn't like to be touched on the belly. Plays well with other dogs.",
14+
},
15+
{
16+
name: "Richard",
17+
ownerName: "Josephine Dane",
18+
imageUrl:
19+
"https://images.unsplash.com/photo-1583337130417-3346a1be7dee?auto=format&fit=crop&q=100&w=1964&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
20+
age: 5,
21+
notes: "Needs medication twice a day.",
22+
},
23+
{
24+
name: "Anna",
25+
ownerName: "Frank Doe",
26+
imageUrl:
27+
"https://images.unsplash.com/photo-1537151625747-768eb6cf92b2?auto=format&fit=crop&q=100&w=1970&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
28+
age: 4,
29+
notes: "Allergic to chicken.",
30+
},
31+
];
32+
33+
async function main() {
34+
console.log(`Start seeding ...`);
35+
36+
for (const pet of pets) {
37+
const result = await prisma.pet.create({
38+
data: pet,
39+
});
40+
console.log(`Created pet with id: ${result.id}`);
41+
}
42+
43+
console.log(`Seeding finished.`);
44+
}
45+
46+
main()
47+
.then(async () => {
48+
await prisma.$disconnect();
49+
})
50+
.catch(async (e) => {
51+
console.error(e);
52+
await prisma.$disconnect();
53+
process.exit(1);
54+
});

0 commit comments

Comments
 (0)