stacker.news/prisma/seed.js

81 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-03-25 19:29:24 +00:00
const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
async function main () {
const k00b = await prisma.user.upsert({
where: { name: 'k00b' },
update: {},
create: {
2021-04-14 00:57:32 +00:00
name: 'k00b'
2021-03-25 19:29:24 +00:00
}
})
const satoshi = await prisma.user.upsert({
where: { name: 'satoshi' },
update: {},
create: {
2021-04-14 00:57:32 +00:00
name: 'satoshi'
2021-03-25 19:29:24 +00:00
}
})
2021-04-12 18:05:09 +00:00
const greg = await prisma.user.upsert({
where: { name: 'greg' },
update: {},
create: {
name: 'greg'
}
})
const stan = await prisma.user.upsert({
where: { name: 'stan' },
update: {},
create: {
name: 'stan'
}
})
await prisma.item.upsert({
where: { id: 0 },
update: {},
create: {
2021-04-14 00:57:32 +00:00
title: 'System76 Developing “Cosmic” Desktop Environment',
url: 'https://blog.system76.com/post/648371526931038208/cosmic-to-arrive-in-june-release-of-popos-2104',
userId: satoshi.id
}
})
await prisma.item.upsert({
where: { id: 1 },
update: {},
create: {
title: 'Deno 1.9',
url: 'https://deno.com/blog/v1.9',
userId: k00b.id
}
})
await prisma.item.upsert({
where: { id: 2 },
update: {},
create: {
title: '1Password Secrets Automation',
url: 'https://blog.1password.com/introducing-secrets-automation/',
userId: greg.id
}
})
await prisma.item.upsert({
where: { id: 3 },
update: {},
create: {
title: 'Counter Strike Bug Allows Hackers to Take over a PC with a Steam Invite',
url: 'https://www.vice.com/en/article/dyvgej/counter-strike-bug-allows-hackers-to-take-over-a-pc-with-a-steam-invite',
userId: stan.id
2021-04-12 18:05:09 +00:00
}
})
2021-03-25 19:29:24 +00:00
}
main()
.catch(e => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})