45 lines
895 B
JavaScript
45 lines
895 B
JavaScript
const { PrismaClient } = require('@prisma/client')
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
const instanceData = {
|
|
name: "example.com",
|
|
appName: 'fake_app',
|
|
appClientId: "fake_client_id",
|
|
appClientSecret: "fake_client_secret",
|
|
users: {
|
|
create: [
|
|
{
|
|
displayName: 'fake_user',
|
|
handle: '@fakeuser',
|
|
terms: {
|
|
create: [
|
|
{text: "Big Lasers"},
|
|
{text: "Big Monsters!"}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
async function main() {
|
|
console.log(`Start seeding ...`)
|
|
for (const u of instanceData) {
|
|
const instance = await prisma.instance.create({
|
|
data: u,
|
|
})
|
|
console.log(`Created instance with id: ${instance.id}`)
|
|
}
|
|
console.log(`Seeding finished.`)
|
|
}
|
|
|
|
main()
|
|
.then(async () => {
|
|
await prisma.$disconnect()
|
|
})
|
|
.catch(async (e) => {
|
|
console.error(e)
|
|
await prisma.$disconnect()
|
|
process.exit(1)
|
|
})
|