Following tutorial to set up remix app
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Beer {
|
||||
id String @id @default(uuid())
|
||||
name String @unique
|
||||
abv Float
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
const db = new PrismaClient();
|
||||
|
||||
async function seed() {
|
||||
await Promise.all(
|
||||
getBeers().map((beer) => {
|
||||
return db.beer.create({ data: beer });
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
seed();
|
||||
|
||||
function getBeers() {
|
||||
// shout-out to https://icanhazdadjoke.com/
|
||||
|
||||
return [
|
||||
{
|
||||
name: "Ginger Paradise",
|
||||
abv: 6.2
|
||||
},
|
||||
{
|
||||
name: "Hertog Jan Pilsener",
|
||||
abv: 5.1
|
||||
},
|
||||
{
|
||||
name: "Hertog Jan Weizener",
|
||||
abv: 5.7
|
||||
},
|
||||
{
|
||||
name: "Leffe Blond 0,0%",
|
||||
abv: 0.0
|
||||
}
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user