P
Prisma3w ago
Uncle

Cannot read properties of undefined (reading 'create')

I'm getting this error with the following schema a creation process:
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
}
model MagicLink {
tokenHash String @unique @map("token_hash")
email String
expiresAt DateTime @map("expires_at")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["omitApi"]
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
}
model MagicLink {
tokenHash String @unique @map("token_hash")
email String
expiresAt DateTime @map("expires_at")
}
export async function generateMagicLink(email:string):Promise<string> {
const random:RandomReader = {
read(bytes) {
crypto.getRandomValues(bytes)
}
}
const code = generateRandomString(random, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', 25);
console.log('code: ', code)
const codeHash = encodeBase32LowerCaseNoPadding(sha256(new TextEncoder().encode(code)));
console.log('codeHash: ', codeHash);
const magicLink = await prisma.magicLink.create({
data: {
email,
expiresAt: dayjs(Date.now()).add(5, 'minute').toDate(),
tokenHash: codeHash
}
})
console.log(magicLink)
return code;
}
export async function generateMagicLink(email:string):Promise<string> {
const random:RandomReader = {
read(bytes) {
crypto.getRandomValues(bytes)
}
}
const code = generateRandomString(random, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', 25);
console.log('code: ', code)
const codeHash = encodeBase32LowerCaseNoPadding(sha256(new TextEncoder().encode(code)));
console.log('codeHash: ', codeHash);
const magicLink = await prisma.magicLink.create({
data: {
email,
expiresAt: dayjs(Date.now()).add(5, 'minute').toDate(),
tokenHash: codeHash
}
})
console.log(magicLink)
return code;
}
2 Replies
Uncle
UncleOP3w ago
I just updated to 6.0 The rest of my schema is working just fine When I run prisma studio and try to open the MagicLink table I get an Unable to run script error I restarted my computer and things seem to work now
RaphaelEtim
RaphaelEtim3w ago
Hi @Uncle That's a weird one. Please let us know if you run into any more issues.
Want results from more Discord servers?
Add your server