#Prisma with createServerData$

15 messages · Page 1 of 1 (latest)

limber estuary
#

Any idea what I am doing wrong when I query this info from a database?

const prisma = new PrismaClient();

export function routeData() {
  return createServerData$(() => prisma.flashcard.findMany());
}

const Dashboard = () => {
  const fCards = useRouteData<typeof routeData>();
#

console.log returns

[Function: read] { loading: true, error: undefined, state: 'pending' }
reef mesa
#

call fCards

#

fCards()

limber estuary
#

Oh thanks, that addressed the first problem

#

Any idea how to address this issue?

Error: 
Invalid `prisma.flashcard.findMany()` invocation:


error: Error validating datasource `db`: the URL must start with the protocol `file:`.
  -->  schema.prisma:10
   | 
 9 |   provider = "sqlite"
10 |   url      = env("DATABASE_URL")
#

My schema and .env should be fine I think

reef mesa
#

i think provider needs to be file:sqlite

#

oh

#

no sorry

#

what does your .env for the DATABASE_URL look like

#

your DATABASE_URL needs to start with file:

limber estuary
#
// schema
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}
reef mesa
#

did that work?

limber estuary
#

Oh wait I think this fixed it

url      = "file:./prisma/dev.db"