-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.ts
More file actions
37 lines (34 loc) · 709 Bytes
/
seed.ts
File metadata and controls
37 lines (34 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'dotenv/config';
import { prisma } from "./client";
import type { User } from "../generated/client";
const DEFAULT_USERS = [
// Add your own user to pre-populate the database with
{
name: "Tim Apple",
email: "tim@apple.com",
},
] as Array<Partial<User>>;
(async () => {
try {
await Promise.all(
DEFAULT_USERS.map((user) =>
prisma.user.upsert({
where: {
email: user.email!,
},
update: {
...user,
},
create: {
...user,
},
})
)
);
} catch (error) {
console.error(error);
process.exit(1);
} finally {
await prisma.$disconnect();
}
})();